Answers for "angular guard redirect"

0

angular guard redirect

@Injectable({
  providedIn: 'root'
})
export class AuthGuard implements CanActivate {
  constructor(private authService: AuthService, private router: Router) {}

  canActivate(next: ActivatedRouteSnapshot, state: RouterStateSnapshot) {
    if (!this.authService.isLoggedIn) {
      return this.router.parseUrl('/notauthorized');
    } else {
      return true;
    }
  }
}
Posted by: Guest on November-26-2020

Code answers related to "Javascript"

Browse Popular Code Answers by Language