app.factory('Auth', [ '$rootScope', 'localStorageService', '$location', 'azp@oauth3.org' , function($rootScope, localStorageService, $location, Oauth3) { var user; return { setUser: function(currentUser){ user = currentUser; if (redirectedURL === '/splash-page') { $location.path('/home'); } else { $location.path('/' + redirectedURL); } user = localStorageService.set('userAuth', JSON.stringify(currentUser)); }, isLoggedIn: function(){ // TODO check sessions instead user = JSON.parse(localStorageService.get('userAuth')); return (user) ? user : false; }, getProfile: function(profile) { profile = user; return profile; } }; }]);