auth-guard.service.ts 474 B

123456789101112131415161718192021
  1. import { AuthServiceService } from './auth-service.service';
  2. import { Injectable } from '@angular/core';
  3. import { Router, CanActivate } from '@angular/router';
  4. @Injectable({
  5. providedIn: 'root'
  6. })
  7. export class AuthGuardService {
  8. constructor(public auth: AuthServiceService, public router: Router) {}
  9. canActivate(): boolean {
  10. if (this.auth.isAuthenticated()) {
  11. this.router.navigate(['/InternalPage/home']);
  12. return false;
  13. }
  14. return true;
  15. }
  16. }