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
35779b1e
Commit
35779b1e
authored
May 12, 2015
by
Evren Kutar
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
use login service and session
- first time in login process, development going on
parent
c89ac5ea
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
28 additions
and
17 deletions
+28
-17
index.html
app/index.html
+5
-0
login.js
app/login/login.js
+15
-9
login_service.js
app/login/login_service.js
+8
-8
No files found.
app/index.html
View file @
35779b1e
...
...
@@ -51,7 +51,12 @@
<script
type=
"text/javascript"
src=
"bower_components/angular-schema-form/dist/bootstrap-decorator.min.js"
></script>
<script
src=
"app.js"
></script>
<!-- login js -->
<script
src=
"login/login.js"
></script>
<script
src=
"login/login_service.js"
></script>
<script
src=
"dashboard/dashboard.js"
></script>
<script
src=
"components/version/version.js"
></script>
<script
src=
"components/version/version-directive.js"
></script>
...
...
app/login/login.js
View file @
35779b1e
'use strict'
;
// TODO: clean console log items
// TODO: password hash or not??
// TODO: who field can be removed??
angular
.
module
(
'zaerp.login'
,
[
'ngRoute'
,
'schemaForm'
])
.
config
([
'$routeProvider'
,
function
(
$routeProvider
)
{
var
login
=
angular
.
module
(
'zaerp.login'
,
[
'ngRoute'
,
'schemaForm'
]);
login
.
config
([
'$routeProvider'
,
function
(
$routeProvider
)
{
$routeProvider
.
when
(
'/login'
,
{
templateUrl
:
'login/login.html'
,
controller
:
'LoginCtrl'
});
}])
.
controller
(
'LoginCtrl'
,
function
(
$scope
,
$http
,
$location
,
$rootScop
e
)
{
}])
;
login
.
controller
(
'LoginCtrl'
,
function
(
$scope
,
$http
,
$location
,
$rootScope
,
AUTH_EVENTS
,
LoginServic
e
)
{
$scope
.
schema
=
{
title
:
"Login"
,
...
...
@@ -20,7 +21,7 @@ angular.module('zaerp.login', ['ngRoute', 'schemaForm'])
type
:
"email"
,
title
:
"Email"
},
pass
:
{
pass
word
:
{
type
:
"string"
,
title
:
"Password"
},
...
...
@@ -34,9 +35,8 @@ angular.module('zaerp.login', ['ngRoute', 'schemaForm'])
enum
:
[
"student"
,
"stuff"
,
"dean"
]
}
},
required
:
[
"email"
,
"pass"
,
"who"
]
required
:
[
"email"
,
"pass
word
"
,
"who"
]
};
//$scope.fields = ["email", "pass", "who", "remember"];
$scope
.
model
=
{
email
:
"user@example.com"
,
remember
:
false
...
...
@@ -47,7 +47,7 @@ angular.module('zaerp.login', ['ngRoute', 'schemaForm'])
type
:
"email"
},
{
key
:
"pass"
,
key
:
"pass
word
"
,
type
:
"password"
},
"remember"
,
...
...
@@ -63,6 +63,12 @@ angular.module('zaerp.login', ['ngRoute', 'schemaForm'])
if
(
form
.
$valid
){
$rootScope
.
loggedInUser
=
true
;
$location
.
path
(
"/dashboard"
);
var
credentials
=
{
email
:
form
.
email
,
password
:
form
.
password
};
var
loginResponse
=
LoginService
.
login
(
credentials
);
console
.
log
(
loginResponse
);
//$http.post('http://127.0.0.1:8003/#/login', form.email).
// success(function(data, status, headers, config){
// console.log(data);
...
...
app/login/login_service.js
View file @
35779b1e
...
...
@@ -6,12 +6,12 @@
// TODO: login url cheange with correct one
angular
.
factory
(
'LoginService'
,
function
(
$http
,
Session
)
{
login
.
factory
(
'LoginService'
,
function
(
$http
,
Session
)
{
var
loginService
=
{};
loginService
.
login
=
function
(
credentials
)
{
return
$http
.
pos
t
(
'http://127.0.0.1:8000/login'
,
credentials
)
.
ge
t
(
'http://127.0.0.1:8000/login'
,
credentials
)
.
then
(
function
(
res
)
{
Session
.
create
(
res
.
data
.
id
,
res
.
data
.
user
.
id
,
res
.
data
.
user
.
role
);
...
...
@@ -19,24 +19,24 @@ angular.factory('LoginService', function ($http, Session) {
});
};
auth
Service
.
isAuthenticated
=
function
()
{
login
Service
.
isAuthenticated
=
function
()
{
return
!!
Session
.
userId
;
};
auth
Service
.
isAuthorized
=
function
(
authorizedRoles
)
{
login
Service
.
isAuthorized
=
function
(
authorizedRoles
)
{
if
(
!
angular
.
isArray
(
authorizedRoles
))
{
authorizedRoles
=
[
authorizedRoles
];
}
return
(
auth
Service
.
isAuthenticated
()
&&
authorizedRoles
.
indexOf
(
Session
.
userRole
)
!==
-
1
);
return
(
login
Service
.
isAuthenticated
()
&&
loginService
.
indexOf
(
Session
.
userRole
)
!==
-
1
);
};
return
auth
Service
;
return
login
Service
;
});
// TODO: initial service not working!!
angular
.
service
(
'Session'
,
function
()
{
login
.
service
(
'Session'
,
function
()
{
this
.
create
=
function
(
sessionId
,
userId
,
userRole
)
{
this
.
id
=
sessionId
;
this
.
userId
=
userId
;
...
...
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