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