Every time I launch my application, it redirects me to /signin
automatically. However, when I attempt to access the /signup
page, it fails to redirect. Is there a way to use next
to direct to /signup
when the path is http://localhost:9000/signup
? Any suggestions?
user.service.js:
angular.module('crud').service('User', function($sails) {
return {
isLoggedIn: function() {
this.getUser();
},
setUser: function(aUser) {
localStorage.setItem('User', JSON.stringify(aUser));
},
getUser: function() {
return localStorage.getItem('User');
//console.log('retrievedObject: ', JSON.parse(retrievedObject));
}
}
});
APP.js:
.run(function($rootScope, $location, $log, User) {
$rootScope.$on("$locationChangeStart", function(event, next, current, jwtHelper) {
if (!User.isLoggedIn()) {
$location.path("/signin");
} else if (next === "http://localhost:9000/signup") {
$location.path("/signup");
}
});