Please enable JavaScript.
Coggle requires JavaScript to display documents.
Angular Auth - Coggle Diagram
Angular Auth
Interceptor
-
add into moudle
providers: [..., { provide: HTTP_INTERCEPTOR, useClass: AuthInterceptorService, multi: true}]
-
-
Add AuthGuard
Setup
-
CanActivate(route: ActivatedRouteSnapshot, router: RouterStateSnapshot) : boolean | Promise<boolean> | Observable<boolean> {...}
-
use UrlTree
return this.authService.user.pipe( take(1), map( user => { const isAuth = !!user; if(isAuth){ return true; } return this.router.createUrlTree(['/auth']) }))
Add to Route
{ path: 'recipe', ..., canActivate: [ AuthGuard ] }
-
-