Skip to content

Instantly share code, notes, and snippets.

@sonicoder86
Created June 25, 2016 09:01
Show Gist options
  • Save sonicoder86/50181dd05815ffcf89e81210b74ac312 to your computer and use it in GitHub Desktop.
Save sonicoder86/50181dd05815ffcf89e81210b74ac312 to your computer and use it in GitHub Desktop.
Authentication in Angular 2 - part 6
// 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