1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2024-12-12 23:09:03 +01:00
fab-manager/app/assets/javascripts/services/auth.js.erb

18 lines
483 B
Plaintext

'use strict';
Application.Services.factory('AuthService', ['Session', 'CSRF', function (Session, CSRF) {
return {
isAuthenticated () {
return (Session.currentUser != null) && (Session.currentUser.id != null);
},
isAuthorized (authorizedRoles) {
if (!angular.isArray(authorizedRoles)) {
authorizedRoles = [authorizedRoles];
}
return this.isAuthenticated() && (authorizedRoles.indexOf(Session.currentUser.role) !== -1);
}
};
}]);