Created
June 25, 2016 09:01
-
-
Save sonicoder86/50181dd05815ffcf89e81210b74ac312 to your computer and use it in GitHub Desktop.
Authentication in Angular 2 - part 6
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// user.service.ts | |
export function isLoggedIn() { | |
return !!storage.getAuthToken(); | |
} | |
// profile.component.ts | |
import { Component } from '@angular/core'; | |
import { CanActivate } from '@angular/router-deprecated'; | |
import { isLoggedIn } from './user.service'; | |
@Component({ | |
selector: 'profile', | |
template: `...` | |
}) | |
@CanActivate(isLoggedIn) | |
export class ProfileComponent {} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment