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
2939ec2d
Commit
2939ec2d
authored
Nov 03, 2015
by
Evren Kutar
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
duplicated auth service removed
parent
6346f0cb
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
0 additions
and
77 deletions
+0
-77
auth_controller.js
app/components/auth/auth_controller.js
+0
-77
No files found.
app/components/auth/auth_controller.js
View file @
2939ec2d
...
...
@@ -12,7 +12,6 @@ auth.controller('LoginCtrl', function ($scope, $q, $timeout, $routeParams, Gener
$scope
.
url
=
'login'
;
$scope
.
form_params
=
{};
$scope
.
form_params
[
'clear_wf'
]
=
1
;
// todo: change simple login when api ready
Generator
.
get_form
(
$scope
).
then
(
function
(
data
){
$scope
.
form
=
[
{
key
:
"username"
,
type
:
"string"
,
title
:
"Kullanıcı Adı"
},
...
...
@@ -33,79 +32,3 @@ auth.controller('LoginCtrl', function ($scope, $q, $timeout, $routeParams, Gener
}
}
});
\ No newline at end of file
auth
.
factory
(
'LoginService'
,
function
(
$http
,
$rootScope
,
$location
,
$log
,
$cookies
,
$window
,
Session
,
RESTURL
)
{
var
loginService
=
{};
loginService
.
login
=
function
(
url
,
credentials
)
{
credentials
=
{
login_crd
:
credentials
,
cmd
:
"do"
};
return
$http
.
post
(
RESTURL
.
url
+
url
,
credentials
)
.
success
(
function
(
data
,
status
,
headers
,
config
)
{
//$window.sessionStorage.token = data.token;
//$rootScope.loggedInUser = true;
})
.
error
(
function
(
data
,
status
,
headers
,
config
)
{
// Erase the token if the user fails to log in
//delete $window.sessionStorage.token;
// Handle login errors here
return
data
;
});
//.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
.
logout
=
function
()
{
$http
.
post
(
RESTURL
.
url
+
'logout'
,
{}).
then
(
function
(){
$rootScope
.
loggedInUser
=
false
;
$location
.
path
(
"/login"
);
});
};
loginService
.
isAuthenticated
=
function
()
{
return
!!
Session
.
userId
;
};
loginService
.
isAuthorized
=
function
(
authorizedRoles
)
{
if
(
!
angular
.
isArray
(
authorizedRoles
))
{
authorizedRoles
=
[
authorizedRoles
];
}
return
(
loginService
.
isAuthenticated
()
&&
loginService
.
indexOf
(
Session
.
userRole
)
!==
-
1
);
};
loginService
.
isValidEmail
=
function
(
email
)
{
var
re
=
/^
([\w
-
]
+
(?:\.[\w
-
]
+
)
*
)
@
((?:[\w
-
]
+
\.)
*
\w[\w
-
]{0,66})\.([
a-z
]{2,6}(?:\.[
a-z
]{2})?)
$/i
;
return
re
.
test
(
email
);
};
return
loginService
;
});
// TODO: initial service not working!!
auth
.
service
(
'Session'
,
function
()
{
this
.
create
=
function
(
sessionId
,
userId
,
userRole
)
{
this
.
id
=
sessionId
;
this
.
userId
=
userId
;
this
.
userRole
=
userRole
;
};
this
.
destroy
=
function
()
{
this
.
id
=
null
;
this
.
userId
=
null
;
this
.
userRole
=
null
;
};
});
\ No newline at end of file
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