Skip to content

Instantly share code, notes, and snippets.

@seven-cd
Created August 26, 2017 08:53
Show Gist options
  • Save seven-cd/4bcb8243449ad17cc2d4fe656d7f84a3 to your computer and use it in GitHub Desktop.
Save seven-cd/4bcb8243449ad17cc2d4fe656d7f84a3 to your computer and use it in GitHub Desktop.
ng2router-can-activate-guard.js
@Injectable()
export class AuthGuard implements CanActivate {
constructor(
private authService : AuthService
){}
canActivate() {
if(this.authService.loggedIn) {
return this.authService.loggedIn;
} else {
alert('You are unathorized. Please login');
return false;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment