File

src/app/guards/log-out.guard.ts

Index

Methods

Constructor

constructor(authService: AuthService, storage: StorageService, timeoutService: TimeoutService, router: Router)
Parameters :
Name Type Optional
authService AuthService no
storage StorageService no
timeoutService TimeoutService no
router Router no

Methods

canActivate
canActivate()
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;
  }
}

results matching ""

    No results matching ""