[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:
Thomas Rittson 2022-04-30 10:51:33 +10:00 committed by GitHub
parent 1f0d496f21
commit 446f2027b4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 11 deletions

2
jslib

@ -1 +1 @@
Subproject commit d7e554653a7e593f8cdaf7e2fe926eb04fb5d5c5
Subproject commit 2e2849b4def0534f3f72b7a84c3183ab0b1589f2

View File

@ -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 });

View File

@ -3,7 +3,6 @@ import { ToastrModule } from "ngx-toastr";
import {
JslibServicesModule,
WINDOW,
SECURE_STORAGE,
STATE_FACTORY,
STATE_SERVICE_USE_CACHE,