mirror of
https://github.com/bitwarden/browser.git
synced 2024-12-28 17:27:50 +01:00
Use jslib unauthGuard, add lockGuard support (#939)
* Use jslib unauthGuard, add lockGuard support * bump jslib
This commit is contained in:
parent
714a574028
commit
9b38095aba
2
jslib
2
jslib
@ -1 +1 @@
|
||||
Subproject commit 3c872e56f27ae78fb922b765d7601886b5c39f78
|
||||
Subproject commit 36641f07b9807d90270ccd743d16b903cb558078
|
@ -33,13 +33,6 @@ export class LockComponent extends BaseLockComponent {
|
||||
|
||||
async ngOnInit() {
|
||||
await super.ngOnInit();
|
||||
const authed = await this.userService.isAuthenticated();
|
||||
if (!authed) {
|
||||
this.router.navigate(['/']);
|
||||
} else if (await this.cryptoService.hasKey()) {
|
||||
this.router.navigate(['vault']);
|
||||
}
|
||||
|
||||
this.onSuccessfulSubmit = () => {
|
||||
const previousUrl = this.routerService.getPreviousUrl();
|
||||
if (previousUrl !== '/' && previousUrl.indexOf('lock') === -1) {
|
||||
|
@ -87,9 +87,10 @@ import { VaultComponent } from './vault/vault.component';
|
||||
|
||||
import { OrganizationGuardService } from './services/organization-guard.service';
|
||||
import { OrganizationTypeGuardService } from './services/organization-type-guard.service';
|
||||
import { UnauthGuardService } from './services/unauth-guard.service';
|
||||
|
||||
import { AuthGuardService } from 'jslib/angular/services/auth-guard.service';
|
||||
import { LockGuardService } from 'jslib/angular/services/lock-guard.service';
|
||||
import { UnauthGuardService } from 'jslib/angular/services/unauth-guard.service';
|
||||
|
||||
import { Permissions } from 'jslib/enums/permissions';
|
||||
|
||||
@ -122,7 +123,11 @@ const routes: Routes = [
|
||||
canActivate: [UnauthGuardService],
|
||||
data: { titleId: 'passwordHint' },
|
||||
},
|
||||
{ path: 'lock', component: LockComponent },
|
||||
{
|
||||
path: 'lock',
|
||||
component: LockComponent,
|
||||
canActivate: [LockGuardService],
|
||||
},
|
||||
{ path: 'verify-email', component: VerifyEmailTokenComponent },
|
||||
{
|
||||
path: 'accept-organization',
|
||||
|
@ -16,10 +16,11 @@ import { EventService } from './event.service';
|
||||
import { OrganizationGuardService } from './organization-guard.service';
|
||||
import { OrganizationTypeGuardService } from './organization-type-guard.service';
|
||||
import { RouterService } from './router.service';
|
||||
import { UnauthGuardService } from './unauth-guard.service';
|
||||
|
||||
import { AuthGuardService } from 'jslib/angular/services/auth-guard.service';
|
||||
import { BroadcasterService } from 'jslib/angular/services/broadcaster.service';
|
||||
import { LockGuardService } from 'jslib/angular/services/lock-guard.service';
|
||||
import { UnauthGuardService } from 'jslib/angular/services/unauth-guard.service';
|
||||
import { ValidationService } from 'jslib/angular/services/validation.service';
|
||||
|
||||
import { ApiService } from 'jslib/services/api.service';
|
||||
@ -190,6 +191,7 @@ export function initFactory(): Function {
|
||||
UnauthGuardService,
|
||||
RouterService,
|
||||
EventService,
|
||||
LockGuardService,
|
||||
{ provide: AuditServiceAbstraction, useValue: auditService },
|
||||
{ provide: AuthServiceAbstraction, useValue: authService },
|
||||
{ provide: CipherServiceAbstraction, useValue: cipherService },
|
||||
|
@ -1,29 +0,0 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import {
|
||||
CanActivate,
|
||||
Router,
|
||||
} from '@angular/router';
|
||||
|
||||
import { UserService } from 'jslib/abstractions/user.service';
|
||||
import { VaultTimeoutService } from 'jslib/abstractions/vaultTimeout.service';
|
||||
|
||||
@Injectable()
|
||||
export class UnauthGuardService implements CanActivate {
|
||||
constructor(private vaultTimeoutService: VaultTimeoutService, private userService: UserService,
|
||||
private router: Router) { }
|
||||
|
||||
async canActivate() {
|
||||
const isAuthed = await this.userService.isAuthenticated();
|
||||
if (isAuthed) {
|
||||
const locked = await this.vaultTimeoutService.isLocked();
|
||||
if (locked) {
|
||||
this.router.navigate(['lock']);
|
||||
} else {
|
||||
this.router.navigate(['vault']);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user