ekangularbase
Version:
Authentication service for usermanagement(oidc client)
18 lines (14 loc) • 435 B
text/typescript
import { Injectable } from '@angular/core';
import { CanActivate } from '@angular/router';
import { Router } from '@angular/router';
()
export class AuthGuard implements CanActivate {
constructor(private router: Router) {}
canActivate() {
if (localStorage.getItem('isLoggedin')) {
return true;
}
this.router.navigate(['/login']);
return false;
}
}