blob: 3132a1a772aba6d55287cbfe9a1b5e2cede2b17d (
plain) (
tree)
|
|
import { Injectable } from '@angular/core'
import { ActivatedRouteSnapshot, CanActivate, CanActivateChild, Router, RouterStateSnapshot } from '@angular/router'
import { AuthService } from '../auth/auth.service'
import { RedirectService } from './redirect.service'
@Injectable()
export class UnloggedGuard implements CanActivate, CanActivateChild {
constructor (
private router: Router,
private auth: AuthService,
private redirectService: RedirectService
) {}
canActivate (route: ActivatedRouteSnapshot, state: RouterStateSnapshot) {
if (this.auth.isLoggedIn() === false) return true
this.redirectService.redirectToHomepage()
return false
}
canActivateChild (route: ActivatedRouteSnapshot, state: RouterStateSnapshot) {
return this.canActivate(route, state)
}
}
|