Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
U
ulakbus-ui
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ulakbus
ulakbus-ui
Commits
7ae6ea4d
Commit
7ae6ea4d
authored
Jul 08, 2015
by
Evren Kutar
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
login implementasyonu faz 1
parent
5d272471
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
49 additions
and
40 deletions
+49
-40
app_routes.js
app/app_routes.js
+2
-2
auth_controller.js
app/components/auth/auth_controller.js
+2
-1
auth_service.js
app/components/auth/auth_service.js
+28
-20
staff_controller.js
app/components/staff/staff_controller.js
+5
-2
index.html
app/index.html
+3
-0
form_service.js
app/zetalib/forms/form_service.js
+1
-14
interceptors.js
app/zetalib/interceptors.js
+7
-1
bower.json
bower.json
+1
-0
No files found.
app/app_routes.js
View file @
7ae6ea4d
...
@@ -167,8 +167,8 @@ app.config(['$routeProvider', function ($routeProvider) {
...
@@ -167,8 +167,8 @@ app.config(['$routeProvider', function ($routeProvider) {
*
*
*/
*/
var
sessionId
=
$cookies
.
get
(
'session'
);
//
var sessionId = $cookies.get('session');
$rootScope
.
loggedInUser
=
sessionId
?
true
:
false
;
//
$rootScope.loggedInUser = sessionId ? true : false;
$rootScope
.
$on
(
"$routeChangeStart"
,
function
(
event
,
next
,
current
)
{
$rootScope
.
$on
(
"$routeChangeStart"
,
function
(
event
,
next
,
current
)
{
if
(
$rootScope
.
loggedInUser
==
null
)
{
if
(
$rootScope
.
loggedInUser
==
null
)
{
// no logged user, redirect to /login
// no logged user, redirect to /login
...
...
app/components/auth/auth_controller.js
View file @
7ae6ea4d
...
@@ -17,7 +17,8 @@ auth.controller('LoginCtrl', function ($scope, $q, $timeout, $routeParams, Gener
...
@@ -17,7 +17,8 @@ auth.controller('LoginCtrl', function ($scope, $q, $timeout, $routeParams, Gener
$scope
.
url
=
'simple_login'
;
$scope
.
url
=
'simple_login'
;
// todo: change simple login when api ready
// todo: change simple login when api ready
Generator
.
get_form
(
$scope
.
url
,
$routeParams
).
then
(
function
(
d
){
Generator
.
get_form
(
$scope
.
url
,
$routeParams
).
then
(
function
(
data
){
var
d
=
data
.
data
.
forms
;
$scope
.
schema
=
d
.
schema
;
$scope
.
schema
=
d
.
schema
;
$scope
.
form
=
d
.
form
;
$scope
.
form
=
d
.
form
;
// model is the init data of the form or in edit templates
// model is the init data of the form or in edit templates
...
...
app/components/auth/auth_service.js
View file @
7ae6ea4d
...
@@ -9,31 +9,39 @@
...
@@ -9,31 +9,39 @@
// TODO: login url change with correct one
// TODO: login url change with correct one
auth
.
factory
(
'LoginService'
,
function
(
$http
,
$rootScope
,
$location
,
$log
,
$cookies
,
Session
,
RESTURL
)
{
auth
.
factory
(
'LoginService'
,
function
(
$http
,
$rootScope
,
$location
,
$log
,
$cookies
,
$window
,
Session
,
RESTURL
)
{
var
loginService
=
{};
var
loginService
=
{};
loginService
.
login
=
function
(
url
,
credentials
)
{
loginService
.
login
=
function
(
url
,
credentials
)
{
// TODO: change this getParams var to service to use app-wide
credentials
=
{
login_crd
:
credentials
,
cmd
:
"do"
};
var
getParams
=
"?"
;
for
(
var
k
in
credentials
)
{
getParams
+=
k
+
"="
+
credentials
[
k
]
+
"&"
;
}
return
$http
return
$http
.
get
(
RESTURL
.
url
+
url
+
getParams
)
.
post
(
RESTURL
.
url
+
url
,
credentials
)
.
then
(
function
(
res
)
{
.
success
(
function
(
data
,
status
,
headers
,
config
)
{
$log
.
info
(
res
.
data
[
0
]);
$window
.
sessionStorage
.
token
=
data
.
token
;
res
.
data
=
res
.
data
[
0
];
$rootScope
.
loggedInUser
=
true
;
if
(
res
.
data
.
success
)
{
$location
.
path
(
"/dashboard"
);
$rootScope
.
loggedInUser
=
true
;
})
$location
.
path
(
"/dashboard"
);
.
error
(
function
(
data
,
status
,
headers
,
config
)
{
var
session
=
Session
.
create
(
res
.
data
.
id
,
res
.
data
.
user
.
id
,
// Erase the token if the user fails to log in
res
.
data
.
user
.
role
);
delete
$window
.
sessionStorage
.
token
;
$log
.
info
(
session
);
$cookies
.
put
(
'sessionId'
,
123456
);
// Handle login errors here
console
.
log
(
$cookies
.
getAll
());
$scope
.
message
=
'Error: Invalid user or password'
;
return
res
.
data
.
user
;
}
});
});
//.then(function (res) {
// $log.info(res.data[0]);
// res.data = res.data[0];
// if (res.data.success) {
// $rootScope.loggedInUser = true;
// $location.path("/dashboard");
// var session = Session.create(res.data.id, res.data.user.id,
// res.data.user.role);
// $log.info(session);
// $cookies.put('sessionId', 123456);
// console.log($cookies.getAll());
// return res.data.user;
// }
//});
};
};
loginService
.
isAuthenticated
=
function
()
{
loginService
.
isAuthenticated
=
function
()
{
...
...
app/components/staff/staff_controller.js
View file @
7ae6ea4d
...
@@ -48,18 +48,21 @@ staff.controller('StaffAddEditCtrl', function ($scope, $http, $log, Generator, $
...
@@ -48,18 +48,21 @@ staff.controller('StaffAddEditCtrl', function ($scope, $http, $log, Generator, $
else
{
else
{
form_params
[
'cmd'
]
=
'add_object'
;
form_params
[
'cmd'
]
=
'add_object'
;
}
}
Generator
.
get_form
(
'personel_duzenle_basitlestirilmis'
,
form_params
).
then
(
function
(
d
)
{
Generator
.
get_form
(
'personel_duzenle_basitlestirilmis'
,
form_params
).
then
(
function
(
data
)
{
var
d
=
data
.
data
.
forms
;
$scope
.
schema
=
d
.
schema
;
$scope
.
schema
=
d
.
schema
;
$scope
.
form
=
d
.
form
;
$scope
.
form
=
d
.
form
;
$scope
.
form
.
push
({
"key"
:
"birth_date"
,
"format"
:
"yyyy-mm-dd"
});
$scope
.
model
=
d
.
model
?
d
.
model
:
{};
$scope
.
model
=
d
.
model
?
d
.
model
:
{};
$scope
.
initialModel
=
angular
.
copy
(
d
.
model
);
$scope
.
initialModel
=
angular
.
copy
(
d
.
model
);
$scope
.
form
[
0
].
$asyncValidators
=
Generator
.
asyncValidators
;
//$scope.form.push($asyncValidators: Generator.asyncValidators)
;
$scope
.
form
.
push
(
$scope
.
form
.
push
(
{
{
type
:
"submit"
,
type
:
"submit"
,
title
:
"Save"
title
:
"Save"
}
}
);
);
console
.
log
(
$scope
);
return
$scope
;
return
$scope
;
});
});
$scope
.
onSubmit
=
function
(
form
)
{
$scope
.
onSubmit
=
function
(
form
)
{
...
...
app/index.html
View file @
7ae6ea4d
...
@@ -81,6 +81,9 @@
...
@@ -81,6 +81,9 @@
<script
type=
"text/javascript"
src=
"bower_components/tv4/tv4.js"
></script>
<script
type=
"text/javascript"
src=
"bower_components/tv4/tv4.js"
></script>
<script
type=
"text/javascript"
src=
"bower_components/objectpath/lib/ObjectPath.js"
></script>
<script
type=
"text/javascript"
src=
"bower_components/objectpath/lib/ObjectPath.js"
></script>
<script
type=
"text/javascript"
src=
"bower_components/angular-schema-form/dist/schema-form.min.js"
></script>
<script
type=
"text/javascript"
src=
"bower_components/angular-schema-form/dist/schema-form.min.js"
></script>
<script
type=
"text/javascript"
src=
"bower_components/angular-schema-form-datepicker/"
></script>
<script
type=
"text/javascript"
src=
"bower_components/angular-schema-form-datepicker/bootstrap-datepicker.js"
></script>
<script
type=
"text/javascript"
src=
"bower_components/angular-schema-form/dist/bootstrap-decorator.min.js"
></script>
<script
type=
"text/javascript"
src=
"bower_components/angular-schema-form/dist/bootstrap-decorator.min.js"
></script>
<script
src=
"app.js"
></script>
<script
src=
"app.js"
></script>
...
...
app/zetalib/forms/form_service.js
View file @
7ae6ea4d
...
@@ -16,23 +16,10 @@ form_generator.factory('Generator', function ($http, $q, $log, $timeout, RESTURL
...
@@ -16,23 +16,10 @@ form_generator.factory('Generator', function ($http, $q, $log, $timeout, RESTURL
return
form_items
;
return
form_items
;
};
};
generator
.
get_form
=
function
(
url
,
getParams
)
{
generator
.
get_form
=
function
(
url
,
getParams
)
{
//if (getParams) {
// // if form for edit then url will be
// var params = "";
// for (var k in getParams) {
// params += k + "=" + getParams[k] + "&";
// }
// var formUrl = RESTURL.url + url + '?' + params;
//} else {
// // if form for create then url will be
// var formUrl = RESTURL.url + url;
//}
console
.
log
(
getParams
);
return
$http
return
$http
.
post
(
RESTURL
.
url
+
url
,
getParams
)
.
post
(
RESTURL
.
url
+
url
,
getParams
)
.
then
(
function
(
res
)
{
.
success
(
function
(
res
)
{
if
(
res
.
status
==
200
)
{
if
(
res
.
status
==
200
)
{
console
.
log
(
res
);
return
generator
.
generate
(
res
.
data
);
return
generator
.
generate
(
res
.
data
);
}
}
// todo: cover all other exceptions (4xx, 5xx)
// todo: cover all other exceptions (4xx, 5xx)
...
...
app/zetalib/interceptors.js
View file @
7ae6ea4d
...
@@ -5,7 +5,7 @@
...
@@ -5,7 +5,7 @@
* (GPLv3). See LICENSE.txt for details.
* (GPLv3). See LICENSE.txt for details.
*/
*/
app
.
config
([
'$httpProvider'
,
function
(
$httpProvider
)
{
app
.
config
([
'$httpProvider'
,
function
(
$httpProvider
,
$rootScope
)
{
/**
/**
* the interceptor for all requests to check response
* the interceptor for all requests to check response
* 4xx - 5xx errors will be handled here
* 4xx - 5xx errors will be handled here
...
@@ -13,6 +13,7 @@ app.config(['$httpProvider', function ($httpProvider) {
...
@@ -13,6 +13,7 @@ app.config(['$httpProvider', function ($httpProvider) {
$httpProvider
.
interceptors
.
push
(
function
(
$q
)
{
$httpProvider
.
interceptors
.
push
(
function
(
$q
)
{
return
{
return
{
'request'
:
function
(
config
){
'request'
:
function
(
config
){
// todo: delete console logs
if
(
config
.
method
==
"POST"
){
if
(
config
.
method
==
"POST"
){
console
.
log
(
"post request"
)
console
.
log
(
"post request"
)
}
else
{
}
else
{
...
@@ -22,9 +23,14 @@ app.config(['$httpProvider', function ($httpProvider) {
...
@@ -22,9 +23,14 @@ app.config(['$httpProvider', function ($httpProvider) {
},
},
'response'
:
function
(
response
)
{
'response'
:
function
(
response
)
{
//Will only be called for HTTP up to 300
//Will only be called for HTTP up to 300
if
(
response
.
is_login
){
$rootScope
.
loggedInUser
=
response
.
is_login
;
console
.
log
(
"login"
,
response
.
is_login
);
}
if
(
response
.
screen
)
{
if
(
response
.
screen
)
{
location
.
path
(
response
.
screen
);
location
.
path
(
response
.
screen
);
}
}
console
.
log
(
response
);
return
response
;
return
response
;
},
},
'responseError'
:
function
(
rejection
)
{
'responseError'
:
function
(
rejection
)
{
...
...
bower.json
View file @
7ae6ea4d
...
@@ -13,6 +13,7 @@
...
@@ -13,6 +13,7 @@
"angular-cookies"
:
"1.4.x"
,
"angular-cookies"
:
"1.4.x"
,
"bootstrap"
:
"3.3.4"
,
"bootstrap"
:
"3.3.4"
,
"angular-schema-form"
:
"*"
,
"angular-schema-form"
:
"*"
,
"angular-schema-form-datepicker"
:
"*"
,
"oclazyload"
:
"*"
"oclazyload"
:
"*"
}
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment