Spaces:
Running
Running
| import { Injectable } from '@angular/core'; | |
| import { CanActivate, Router, UrlTree } from '@angular/router'; | |
| import { AuthService } from './auth.service'; | |
| import { AuthUiService } from './auth-ui.service'; | |
| ({ providedIn: 'root' }) | |
| export class AuthGuard implements CanActivate { | |
| constructor(private auth: AuthService, private authUi: AuthUiService, private router: Router) {} | |
| canActivate(): boolean | UrlTree { | |
| if (this.auth.isAuthenticated()) return true; | |
| this.authUi.openSignin(); | |
| return this.router.parseUrl('/'); // redirect home; modal is open | |
| } | |
| } | |