mirror of
https://github.com/bitwarden/web
synced 2025-12-17 16:53:14 +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 { Injectable } from "@angular/core";
|
||||||
import { ActivatedRouteSnapshot, CanActivate, Router } from "@angular/router";
|
import { ActivatedRouteSnapshot, CanActivate, Router } from "@angular/router";
|
||||||
|
|
||||||
import { StateService } from "jslib-common/abstractions/state.service";
|
import { AuthService } from "jslib-common/abstractions/auth.service";
|
||||||
import { VaultTimeoutService } from "jslib-common/abstractions/vaultTimeout.service";
|
import { AuthenticationStatus } from "jslib-common/enums/authenticationStatus";
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class HomeGuard implements CanActivate {
|
export class HomeGuard implements CanActivate {
|
||||||
constructor(
|
constructor(private router: Router, private authService: AuthService) {}
|
||||||
private vaultTimeoutService: VaultTimeoutService,
|
|
||||||
private router: Router,
|
|
||||||
private stateService: StateService
|
|
||||||
) {}
|
|
||||||
|
|
||||||
async canActivate(route: ActivatedRouteSnapshot) {
|
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 });
|
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(["/lock"], { queryParams: route.queryParams });
|
||||||
}
|
}
|
||||||
return this.router.createUrlTree(["/vault"], { queryParams: route.queryParams });
|
return this.router.createUrlTree(["/vault"], { queryParams: route.queryParams });
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ import { ToastrModule } from "ngx-toastr";
|
|||||||
|
|
||||||
import {
|
import {
|
||||||
JslibServicesModule,
|
JslibServicesModule,
|
||||||
WINDOW,
|
|
||||||
SECURE_STORAGE,
|
SECURE_STORAGE,
|
||||||
STATE_FACTORY,
|
STATE_FACTORY,
|
||||||
STATE_SERVICE_USE_CACHE,
|
STATE_SERVICE_USE_CACHE,
|
||||||
|
|||||||
Reference in New Issue
Block a user