From 9b7c0288d429acaf648510b276002ec49fbd0947 Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Fri, 14 Dec 2018 14:22:30 -0500 Subject: [PATCH] inactive 2fa report for orgs --- src/app/app-routing.module.ts | 10 ++++- src/app/app.module.ts | 4 ++ .../inactive-two-factor-report.component.ts | 38 +++++++++++++++++++ .../inactive-two-factor-report.component.ts | 8 +++- 4 files changed, 57 insertions(+), 3 deletions(-) create mode 100644 src/app/organizations/tools/inactive-two-factor-report.component.ts diff --git a/src/app/app-routing.module.ts b/src/app/app-routing.module.ts index fd663f5c96..24bc3afd51 100644 --- a/src/app/app-routing.module.ts +++ b/src/app/app-routing.module.ts @@ -37,6 +37,9 @@ import { ExposedPasswordsReportComponent as OrgExposedPasswordsReportComponent, } from './organizations/tools/exposed-passwords-report.component'; import { ImportComponent as OrgImportComponent } from './organizations/tools/import.component'; +import { + InactiveTwoFactorReportComponent as OrgInactiveTwoFactorReportComponent, +} from './organizations/tools/inactive-two-factor-report.component'; import { ToolsComponent as OrgToolsComponent } from './organizations/tools/tools.component'; import { VaultComponent as OrgVaultComponent } from './organizations/vault/vault.component'; @@ -179,7 +182,7 @@ const routes: Routes = [ { path: 'inactive-two-factor-report', component: InactiveTwoFactorReportComponent, - data: { titleId: 'exposedPasswordsReport' }, + data: { titleId: 'inactive2faReport' }, }, ], }, @@ -206,6 +209,11 @@ const routes: Routes = [ component: OrgExposedPasswordsReportComponent, data: { titleId: 'exposedPasswordsReport' }, }, + { + path: 'inactive-two-factor-report', + component: OrgInactiveTwoFactorReportComponent, + data: { titleId: 'inactive2faReport' }, + }, ], }, { diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 10bdcb353c..1662c336f6 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -67,6 +67,9 @@ import { ExposedPasswordsReportComponent as OrgExposedPasswordsReportComponent, } from './organizations/tools/exposed-passwords-report.component'; import { ImportComponent as OrgImportComponent } from './organizations/tools/import.component'; +import { + InactiveTwoFactorReportComponent as OrgInactiveTwoFactorReportComponent, +} from './organizations/tools/inactive-two-factor-report.component'; import { ToolsComponent as OrgToolsComponent } from './organizations/tools/tools.component'; import { AddEditComponent as OrgAddEditComponent } from './organizations/vault/add-edit.component'; @@ -257,6 +260,7 @@ registerLocaleData(localeZhCn, 'zh-CN'); OrgExportComponent, OrgExposedPasswordsReportComponent, OrgImportComponent, + OrgInactiveTwoFactorReportComponent, OrgGroupAddEditComponent, OrgGroupingsComponent, OrgGroupsComponent, diff --git a/src/app/organizations/tools/inactive-two-factor-report.component.ts b/src/app/organizations/tools/inactive-two-factor-report.component.ts new file mode 100644 index 0000000000..e45b168b21 --- /dev/null +++ b/src/app/organizations/tools/inactive-two-factor-report.component.ts @@ -0,0 +1,38 @@ +import { + Component, + ComponentFactoryResolver, +} from '@angular/core'; +import { ActivatedRoute } from '@angular/router'; + +import { CipherService } from 'jslib/abstractions/cipher.service'; +import { MessagingService } from 'jslib/abstractions/messaging.service'; +import { UserService } from 'jslib/abstractions/user.service'; + +import { + InactiveTwoFactorReportComponent as BaseInactiveTwoFactorReportComponent, +} from '../../tools/inactive-two-factor-report.component'; + +import { CipherView } from 'jslib/models/view/cipherView'; + +@Component({ + selector: 'app-inactive-two-factor-report', + templateUrl: '../../tools/inactive-two-factor-report.component.html', +}) +export class InactiveTwoFactorReportComponent extends BaseInactiveTwoFactorReportComponent { + constructor(ciphersService: CipherService, componentFactoryResolver: ComponentFactoryResolver, + messagingService: MessagingService, userService: UserService, + private route: ActivatedRoute) { + super(ciphersService, componentFactoryResolver, messagingService, userService); + } + + async ngOnInit() { + this.route.parent.parent.params.subscribe(async (params) => { + this.organization = await this.userService.getOrganization(params.organizationId); + await super.ngOnInit(); + }); + } + + getAllCiphers(): Promise { + return this.cipherService.getAllFromApiForOrganization(this.organization.id); + } +} diff --git a/src/app/tools/inactive-two-factor-report.component.ts b/src/app/tools/inactive-two-factor-report.component.ts index 68460ac12c..8bb864d014 100644 --- a/src/app/tools/inactive-two-factor-report.component.ts +++ b/src/app/tools/inactive-two-factor-report.component.ts @@ -24,7 +24,7 @@ export class InactiveTwoFactorReportComponent extends CipherReportComponent impl services = new Map(); cipherDocs = new Map(); - constructor(private ciphersService: CipherService, componentFactoryResolver: ComponentFactoryResolver, + constructor(protected cipherService: CipherService, componentFactoryResolver: ComponentFactoryResolver, messagingService: MessagingService, userService: UserService) { super(componentFactoryResolver, userService, messagingService, true); } @@ -40,7 +40,7 @@ export class InactiveTwoFactorReportComponent extends CipherReportComponent impl await this.load2fa(); } catch { } if (this.services.size > 0) { - const allCiphers = await this.ciphersService.getAllDecrypted(); + const allCiphers = await this.getAllCiphers(); const inactive2faCiphers: CipherView[] = []; const promises: Array> = []; const docs = new Map(); @@ -68,6 +68,10 @@ export class InactiveTwoFactorReportComponent extends CipherReportComponent impl } } + protected getAllCiphers(): Promise { + return this.cipherService.getAllDecrypted(); + } + private async load2fa() { if (this.services.size > 0) { return;