You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Ombi/src/Ombi/ClientApp/src/app/auth/auth.guard.ts

22 lines
556 B

import { Injectable } from "@angular/core";
import { Router } from "@angular/router";
import { CanActivate } from "@angular/router";
import { AuthService } from "./auth.service";
@Injectable()
export class AuthGuard implements CanActivate {
constructor(private auth: AuthService, private router: Router) { }
public canActivate() {
if (this.auth.loggedIn()) {
return true;
} else {
localStorage.removeItem("token");
this.router.navigate(["login"]);
return false;
}
}
}