mirror of
https://github.com/bitwarden/web
synced 2025-12-16 00:03:25 +00:00
[PS-74] Fix user authentication state checks (#1632)
* Update to use new authStatus method * Delete unused services and import * update jslib
This commit is contained in:
2
jslib
2
jslib
Submodule jslib updated: d7e554653a...2e2849b4de
@@ -1,22 +1,20 @@
|
||||
import { Injectable } from "@angular/core";
|
||||
import { ActivatedRouteSnapshot, CanActivate, Router } from "@angular/router";
|
||||
|
||||
import { StateService } from "jslib-common/abstractions/state.service";
|
||||
import { VaultTimeoutService } from "jslib-common/abstractions/vaultTimeout.service";
|
||||
import { AuthService } from "jslib-common/abstractions/auth.service";
|
||||
import { AuthenticationStatus } from "jslib-common/enums/authenticationStatus";
|
||||
|
||||
@Injectable()
|
||||
export class HomeGuard implements CanActivate {
|
||||
constructor(
|
||||
private vaultTimeoutService: VaultTimeoutService,
|
||||
private router: Router,
|
||||
private stateService: StateService
|
||||
) {}
|
||||
constructor(private router: Router, private authService: AuthService) {}
|
||||
|
||||
async canActivate(route: ActivatedRouteSnapshot) {
|
||||
if (!(await this.stateService.getIsAuthenticated())) {
|
||||
const authStatus = await this.authService.getAuthStatus();
|
||||
|
||||
if (authStatus === AuthenticationStatus.LoggedOut) {
|
||||
return this.router.createUrlTree(["/login"], { queryParams: route.queryParams });
|
||||
}
|
||||
if (await this.vaultTimeoutService.isLocked()) {
|
||||
if (authStatus === AuthenticationStatus.Locked) {
|
||||
return this.router.createUrlTree(["/lock"], { queryParams: route.queryParams });
|
||||
}
|
||||
return this.router.createUrlTree(["/vault"], { queryParams: route.queryParams });
|
||||
|
||||
@@ -3,7 +3,6 @@ import { ToastrModule } from "ngx-toastr";
|
||||
|
||||
import {
|
||||
JslibServicesModule,
|
||||
WINDOW,
|
||||
SECURE_STORAGE,
|
||||
STATE_FACTORY,
|
||||
STATE_SERVICE_USE_CACHE,
|
||||
|
||||
Reference in New Issue
Block a user