angular-ngrx-material-starter
angular-ngrx-material-starter copied to clipboard
No redirect from /examples/authenticated if not login.
Minimal reproduction of the bug with instructions:
1- Remove all data from localstorage. 2- Navigate to: https://tomastrajan.github.io/angular-ngrx-material-starter#/examples/authenticated 3- No component/route is loaded after
Expected behavior:
Redirect to /example
or /about
page.
Other information:
Something like this could fix the issue
export class AuthGuardService implements CanActivate {
constructor(private store: Store<AppState>, private router: Router) {}
canActivate(): Observable<boolean> {
this.store.pipe(select(selectIsAuthenticated)).subscribe(isAuth => {
if (isAuth) {
return true;
} else {
this.router.navigateByUrl('/');
return false;
}
})
return this.store.pipe(select(selectIsAuthenticated));
}
}
I would be willing to submit a PR to fix this issue:
[x] Yes (Assistance is provided if you need help submitting a pull request)
[ ] No