2017-08-14 19:35:53 +00:00
|
|
|
app.factory('Auth', [
|
|
|
|
'$rootScope', 'localStorageService', '$location', 'azp@oauth3.org'
|
|
|
|
, function($rootScope, localStorageService, $location, Oauth3) {
|
2017-08-09 18:41:43 +00:00
|
|
|
var user;
|
2017-08-14 19:35:53 +00:00
|
|
|
|
|
|
|
return {
|
2017-08-11 15:09:41 +00:00
|
|
|
setUser: function(currentUser){
|
2017-08-09 18:41:43 +00:00
|
|
|
user = currentUser;
|
2017-08-10 22:33:54 +00:00
|
|
|
if (redirectedURL === '/splash-page') {
|
2017-08-11 21:37:06 +00:00
|
|
|
$location.path('/home');
|
2017-08-10 22:33:54 +00:00
|
|
|
} else {
|
2017-08-11 21:37:06 +00:00
|
|
|
$location.path('/' + redirectedURL);
|
2017-08-10 22:33:54 +00:00
|
|
|
}
|
2017-08-14 19:35:53 +00:00
|
|
|
user = localStorageService.set('userAuth', JSON.stringify(currentUser));
|
2017-08-09 18:41:43 +00:00
|
|
|
},
|
2017-08-11 15:09:41 +00:00
|
|
|
isLoggedIn: function(){
|
2017-08-14 19:35:53 +00:00
|
|
|
// TODO check sessions instead
|
2017-08-09 18:41:43 +00:00
|
|
|
user = JSON.parse(localStorageService.get('userAuth'));
|
|
|
|
return (user) ? user : false;
|
2017-08-11 15:09:41 +00:00
|
|
|
},
|
|
|
|
getProfile: function(profile) {
|
|
|
|
profile = user;
|
|
|
|
return profile;
|
2017-08-09 18:41:43 +00:00
|
|
|
}
|
|
|
|
};
|
2017-08-09 04:23:19 +00:00
|
|
|
}]);
|