mirror of
https://github.com/LaCasemate/fab-manager.git
synced 2024-12-01 12:24:28 +01:00
fix AUthService factory, isAuthenticated was called from scope and not from the factory itself
This commit is contained in:
parent
0b899fe183
commit
6550428f72
@ -1,17 +1,18 @@
|
||||
'use strict';
|
||||
|
||||
Application.Services.factory('AuthService', ['Session', 'CSRF', function (Session, CSRF) {
|
||||
return {
|
||||
isAuthenticated () {
|
||||
return (Session.currentUser != null) && (Session.currentUser.id != null);
|
||||
},
|
||||
let service = {};
|
||||
|
||||
isAuthorized (authorizedRoles) {
|
||||
if (!angular.isArray(authorizedRoles)) {
|
||||
authorizedRoles = [authorizedRoles];
|
||||
}
|
||||
|
||||
return this.isAuthenticated() && (authorizedRoles.indexOf(Session.currentUser.role) !== -1);
|
||||
}
|
||||
service.isAuthenticated = function() {
|
||||
return (Session.currentUser != null) && (Session.currentUser.id != null);
|
||||
};
|
||||
|
||||
service.isAuthorized = function(authorizedRoles) {
|
||||
if (!angular.isArray(authorizedRoles)) {
|
||||
authorizedRoles = [authorizedRoles];
|
||||
}
|
||||
return service.isAuthenticated() && (authorizedRoles.indexOf(Session.currentUser.role) !== -1);
|
||||
};
|
||||
|
||||
return service;
|
||||
}]);
|
||||
|
Loading…
Reference in New Issue
Block a user