Add guards to lock and login routes

This commit is contained in:
Thomas Rittson 2021-04-20 14:01:33 +10:00
parent cdc8191f39
commit 62ccf420a2
2 changed files with 17 additions and 2 deletions

View File

@ -5,6 +5,8 @@ import {
} from '@angular/router'; } from '@angular/router';
import { AuthGuardService } from 'jslib/angular/services/auth-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 { HintComponent } from './accounts/hint.component'; import { HintComponent } from './accounts/hint.component';
import { LockComponent } from './accounts/lock.component'; import { LockComponent } from './accounts/lock.component';
@ -20,8 +22,17 @@ import { VaultComponent } from './vault/vault.component';
const routes: Routes = [ const routes: Routes = [
{ path: '', redirectTo: '/vault', pathMatch: 'full' }, { path: '', redirectTo: '/vault', pathMatch: 'full' },
{ path: 'lock', component: LockComponent }, {
{ path: 'login', component: LoginComponent }, path: 'lock',
component: LockComponent,
canActivate: [lockGuardService],
},
{
path: 'login',
component: LoginComponent,
canActivate: [UnauthGuardService],
},
{ path: '2fa', component: TwoFactorComponent }, { path: '2fa', component: TwoFactorComponent },
{ path: 'register', component: RegisterComponent }, { path: 'register', component: RegisterComponent },
{ {

View File

@ -19,6 +19,8 @@ import { I18nService } from '../services/i18n.service';
import { NativeMessagingService } from '../services/nativeMessaging.service'; import { NativeMessagingService } from '../services/nativeMessaging.service';
import { AuthGuardService } from 'jslib/angular/services/auth-guard.service'; import { AuthGuardService } from 'jslib/angular/services/auth-guard.service';
import { UnauthGuardService } from 'jslib/angular/services/unauth-guard.service';
import { lockGuardService } from 'jslib/angular/services/lock-guard.service';
import { BroadcasterService } from 'jslib/angular/services/broadcaster.service'; import { BroadcasterService } from 'jslib/angular/services/broadcaster.service';
import { ValidationService } from 'jslib/angular/services/validation.service'; import { ValidationService } from 'jslib/angular/services/validation.service';
@ -186,6 +188,8 @@ export function initFactory(): Function {
providers: [ providers: [
ValidationService, ValidationService,
AuthGuardService, AuthGuardService,
UnauthGuardService,
lockGuardService,
{ provide: AuditServiceAbstraction, useValue: auditService }, { provide: AuditServiceAbstraction, useValue: auditService },
{ provide: AuthServiceAbstraction, useValue: authService }, { provide: AuthServiceAbstraction, useValue: authService },
{ provide: CipherServiceAbstraction, useValue: cipherService }, { provide: CipherServiceAbstraction, useValue: cipherService },