mirror of
https://github.com/bitwarden/browser
synced 2025-12-19 01:33:33 +00:00
* [deps] Autofill: Update prettier to v3 * prettier formatting updates --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Jonathan Prusik <jprusik@classynemesis.com>
29 lines
800 B
TypeScript
29 lines
800 B
TypeScript
import { Injectable } from "@angular/core";
|
|
import { CanActivate, Router } from "@angular/router";
|
|
|
|
import { AuthService } from "@bitwarden/common/auth/abstractions/auth.service";
|
|
import { AuthenticationStatus } from "@bitwarden/common/auth/enums/authentication-status";
|
|
|
|
@Injectable()
|
|
export class UnauthGuard implements CanActivate {
|
|
protected homepage = "vault";
|
|
constructor(
|
|
private authService: AuthService,
|
|
private router: Router,
|
|
) {}
|
|
|
|
async canActivate() {
|
|
const authStatus = await this.authService.getAuthStatus();
|
|
|
|
if (authStatus === AuthenticationStatus.LoggedOut) {
|
|
return true;
|
|
}
|
|
|
|
if (authStatus === AuthenticationStatus.Locked) {
|
|
return this.router.createUrlTree(["lock"]);
|
|
}
|
|
|
|
return this.router.createUrlTree([this.homepage]);
|
|
}
|
|
}
|