docs: add JSDoc comments to AuthGuard

This commit is contained in:
Chneemann 2024-11-14 04:48:19 +01:00
parent daf23c1c5c
commit c2ea6c8762

View file

@ -10,6 +10,12 @@ import { LoginService } from './services/auth.service';
export class AuthGuard { export class AuthGuard {
constructor(private loginService: LoginService, private router: Router) {} constructor(private loginService: LoginService, private router: Router) {}
/**
* The canActivate guard checks if the user is authenticated.
* If the user is authenticated, the guard returns true.
* If the user is not authenticated, the guard navigates to the root route and returns false.
* If an error occurs during the authentication check, the guard navigates to the root route and returns false.
*/
canActivate(): Observable<boolean> | Promise<boolean> | boolean { canActivate(): Observable<boolean> | Promise<boolean> | boolean {
return this.loginService.checkAuthUser().pipe( return this.loginService.checkAuthUser().pipe(
map((isAuthenticated) => { map((isAuthenticated) => {