2016-06-09 13:00:26 -05:00
|
|
|
// #docregion
|
2016-07-06 01:11:00 -07:00
|
|
|
import { Injectable } from '@angular/core';
|
|
|
|
import { CanActivate, Router } from '@angular/router';
|
|
|
|
import { AuthService } from './auth.service';
|
2016-06-09 13:00:26 -05:00
|
|
|
|
|
|
|
@Injectable()
|
|
|
|
export class AuthGuard implements CanActivate {
|
|
|
|
constructor(private authService: AuthService, private router: Router) {}
|
|
|
|
|
2016-07-06 01:11:00 -07:00
|
|
|
canActivate() {
|
2016-06-09 13:00:26 -05:00
|
|
|
if (this.authService.isLoggedIn) { return true; }
|
|
|
|
this.router.navigate(['/login']);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|