12345678910111213141516171819202122232425 |
- import { AuthServiceService } from './auth-service.service';
- import { Injectable } from '@angular/core';
- import { Router, CanActivate } from '@angular/router';
- import { Location } from '@angular/common';
- @Injectable({
- providedIn: 'root'
- })
- export class AuthGuardService {
- constructor(public auth: AuthServiceService,
- private location: Location,
- public router: Router) {}
- canActivate(): boolean {
- if (this.auth.isAuthenticated()) {
- this.router.navigate(['/login']);
- return false;
- }
- return true;
- }
- }
|