src/app/guards/log-out.guard.ts
Methods |
constructor(authService: AuthService, storage: StorageService, timeoutService: TimeoutService, router: Router)
|
|||||||||||||||
Defined in src/app/guards/log-out.guard.ts:11
|
|||||||||||||||
Parameters :
|
canActivate |
canActivate()
|
Defined in src/app/guards/log-out.guard.ts:19
|
Returns :
boolean
|
import { AUTH_API, JWT_KEY } from '../app.constants';
import { Http } from '@angular/http';
import { Injectable } from '@angular/core';
import { CanActivate, Router } from '@angular/router';
import { TimeoutService } from '../timeout';
import { AuthService } from '../services/auth.service';
import { StorageService } from '../services';
@Injectable()
export class LogOutGuard implements CanActivate {
constructor(
private authService: AuthService,
private storage: StorageService,
private timeoutService: TimeoutService,
private router: Router
) {}
canActivate() {
this.timeoutService.stopTimer();
this.storage.delete(JWT_KEY);
this.authService.logout();
return false;
}
}