Back to path after login
This commit is contained in:
@@ -7,14 +7,20 @@ import { AuthService } from './auth.service';
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class AuthGuard {
|
||||
loginUrl: string | null = null;
|
||||
constructor(
|
||||
private auth$: AuthService,
|
||||
private router$: Router
|
||||
private router$: Router,
|
||||
) {}
|
||||
canActivate(): Observable<boolean | UrlTree> | Promise<boolean | UrlTree> | boolean | UrlTree {
|
||||
if (this.auth$.user && this.auth$.user.googleCredentials) {
|
||||
if (this.loginUrl) {
|
||||
this.router$.navigate([this.loginUrl]);
|
||||
this.loginUrl = null;
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
this.loginUrl = window.location.pathname;
|
||||
this.router$.navigate(['']);
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user