py-trade / src /app /auth /auth.guard.ts
Oviya
update signin page
a828e09
import { Injectable } from '@angular/core';
import { CanActivate, Router, UrlTree } from '@angular/router';
import { AuthService } from './auth.service';
import { AuthUiService } from './auth-ui.service';
@Injectable({ 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
}
}