py-match / src /app /services /auth.guard.ts
pykara's picture
Upload 5840 files
38fa174 verified
import { Injectable } from '@angular/core';
import { CanActivate, Router } from '@angular/router';
import { AuthService } from './auth.service';
@Injectable({
providedIn: 'root',
})
export class AuthGuard implements CanActivate {
constructor(private auth: AuthService, private router: Router) { }
canActivate(): boolean {
if (this.auth.isAuthenticated) {
return true;
} else {
// Redirect to signin and show modal
this.router.navigate(['/'], { queryParams: { showSignIn: true } });
return false;
}
}
}