-
Notifications
You must be signed in to change notification settings - Fork 182
Open
Description
Implemented CanActivate to guard the routes, and navigating to /login if the user is not logged in, but i can see it is redirecting with POST request, which results to 404 error.
@Injectable()
export class AuthGuard implements CanActivate {
constructor(private router: Router) { }
canActivate() {
console.log("canActivate : AuthGuard");
if (localStorage.getItem('currentUser')) {
// logged in so return true
return true;
}
// not logged in so redirect to login page
this.router.navigate(['/login']);
return false;
}
}
http://stackoverflow.com/questions/40393609/angular2-router-canactivate-is-redirecting-with-post-request
Metadata
Metadata
Assignees
Labels
No labels