diff --git a/src/app/tools/cipher-report.component.ts b/src/app/tools/cipher-report.component.ts index 50ed7d78cc..238bb93704 100644 --- a/src/app/tools/cipher-report.component.ts +++ b/src/app/tools/cipher-report.component.ts @@ -9,6 +9,9 @@ import { CipherView } from 'jslib/models/view/cipherView'; import { ModalComponent } from '../modal.component'; import { AddEditComponent } from '../vault/add-edit.component'; +import { MessagingService } from 'jslib/abstractions/messaging.service'; +import { UserService } from 'jslib/abstractions/user.service'; + export class CipherReportComponent { @ViewChild('cipherAddEdit', { read: ViewContainerRef }) cipherAddEditModalRef: ViewContainerRef; @@ -18,7 +21,8 @@ export class CipherReportComponent { private modal: ModalComponent = null; - constructor(private componentFactoryResolver: ComponentFactoryResolver) { } + constructor(private componentFactoryResolver: ComponentFactoryResolver, protected userService: UserService, + protected messagingService: MessagingService, public requiresPremium: boolean) { } async load() { this.loading = true; @@ -54,6 +58,16 @@ export class CipherReportComponent { return childComponent; } + protected async checkPremium(): Promise { + const accessPremium = await this.userService.canAccessPremium(); + if (this.requiresPremium && !accessPremium) { + this.messagingService.send('premiumRequired'); + this.loading = false; + return false; + } + return true; + } + protected async setCiphers() { this.ciphers = []; } diff --git a/src/app/tools/exposed-passwords-report.component.ts b/src/app/tools/exposed-passwords-report.component.ts index b6a42c6fac..2b01cec703 100644 --- a/src/app/tools/exposed-passwords-report.component.ts +++ b/src/app/tools/exposed-passwords-report.component.ts @@ -1,10 +1,13 @@ import { Component, ComponentFactoryResolver, + OnInit, } from '@angular/core'; import { AuditService } from 'jslib/abstractions/audit.service'; import { CipherService } from 'jslib/abstractions/cipher.service'; +import { MessagingService } from 'jslib/abstractions/messaging.service'; +import { UserService } from 'jslib/abstractions/user.service'; import { CipherView } from 'jslib/models/view/cipherView'; @@ -16,12 +19,23 @@ import { CipherReportComponent } from './cipher-report.component'; selector: 'app-exposed-passwords-report', templateUrl: 'exposed-passwords-report.component.html', }) -export class ExposedPasswordsReportComponent extends CipherReportComponent { +export class ExposedPasswordsReportComponent extends CipherReportComponent implements OnInit { exposedPasswordMap = new Map(); constructor(private ciphersService: CipherService, private auditService: AuditService, - componentFactoryResolver: ComponentFactoryResolver) { - super(componentFactoryResolver); + componentFactoryResolver: ComponentFactoryResolver, messagingService: MessagingService, + userService: UserService) { + super(componentFactoryResolver, userService, messagingService, true); + } + + ngOnInit() { + this.checkPremium(); + } + + async load() { + if (await this.checkPremium()) { + super.load(); + } } async setCiphers() { diff --git a/src/app/tools/inactive-two-factor-report.component.ts b/src/app/tools/inactive-two-factor-report.component.ts index 836e7cf212..5c4e4e1a25 100644 --- a/src/app/tools/inactive-two-factor-report.component.ts +++ b/src/app/tools/inactive-two-factor-report.component.ts @@ -5,6 +5,8 @@ import { } from '@angular/core'; import { CipherService } from 'jslib/abstractions/cipher.service'; +import { MessagingService } from 'jslib/abstractions/messaging.service'; +import { UserService } from 'jslib/abstractions/user.service'; import { CipherView } from 'jslib/models/view/cipherView'; @@ -22,12 +24,15 @@ export class InactiveTwoFactorReportComponent extends CipherReportComponent impl services = new Map(); cipherDocs = new Map(); - constructor(private ciphersService: CipherService, componentFactoryResolver: ComponentFactoryResolver) { - super(componentFactoryResolver); + constructor(private ciphersService: CipherService, componentFactoryResolver: ComponentFactoryResolver, + messagingService: MessagingService, userService: UserService) { + super(componentFactoryResolver, userService, messagingService, true); } - ngOnInit() { - this.load(); + async ngOnInit() { + if (await this.checkPremium()) { + await super.load(); + } } async setCiphers() { diff --git a/src/app/tools/reused-passwords-report.component.html b/src/app/tools/reused-passwords-report.component.html index 551b195d85..b099e60186 100644 --- a/src/app/tools/reused-passwords-report.component.html +++ b/src/app/tools/reused-passwords-report.component.html @@ -10,7 +10,7 @@
-
+
{{'noReusedPasswords'}} diff --git a/src/app/tools/reused-passwords-report.component.ts b/src/app/tools/reused-passwords-report.component.ts index 4d18f9fbd8..08c7886c61 100644 --- a/src/app/tools/reused-passwords-report.component.ts +++ b/src/app/tools/reused-passwords-report.component.ts @@ -5,6 +5,8 @@ import { } from '@angular/core'; import { CipherService } from 'jslib/abstractions/cipher.service'; +import { MessagingService } from 'jslib/abstractions/messaging.service'; +import { UserService } from 'jslib/abstractions/user.service'; import { CipherView } from 'jslib/models/view/cipherView'; @@ -19,12 +21,15 @@ import { CipherReportComponent } from './cipher-report.component'; export class ReusedPasswordsReportComponent extends CipherReportComponent implements OnInit { passwordUseMap: Map; - constructor(private ciphersService: CipherService, componentFactoryResolver: ComponentFactoryResolver) { - super(componentFactoryResolver); + constructor(private ciphersService: CipherService, componentFactoryResolver: ComponentFactoryResolver, + messagingService: MessagingService, userService: UserService) { + super(componentFactoryResolver, userService, messagingService, true); } - ngOnInit() { - this.load(); + async ngOnInit() { + if (await this.checkPremium()) { + await super.load(); + } } async setCiphers() { diff --git a/src/app/tools/unsecured-websites-report.component.html b/src/app/tools/unsecured-websites-report.component.html index 81b52debda..b128c3dd2d 100644 --- a/src/app/tools/unsecured-websites-report.component.html +++ b/src/app/tools/unsecured-websites-report.component.html @@ -10,7 +10,7 @@
-
+
{{'noUnsecuredWebsites'}} diff --git a/src/app/tools/unsecured-websites-report.component.ts b/src/app/tools/unsecured-websites-report.component.ts index ef53b038b0..b1c5d4feb8 100644 --- a/src/app/tools/unsecured-websites-report.component.ts +++ b/src/app/tools/unsecured-websites-report.component.ts @@ -5,6 +5,8 @@ import { } from '@angular/core'; import { CipherService } from 'jslib/abstractions/cipher.service'; +import { MessagingService } from 'jslib/abstractions/messaging.service'; +import { UserService } from 'jslib/abstractions/user.service'; import { CipherType } from 'jslib/enums/cipherType'; @@ -15,12 +17,15 @@ import { CipherReportComponent } from './cipher-report.component'; templateUrl: 'unsecured-websites-report.component.html', }) export class UnsecuredWebsitesReportComponent extends CipherReportComponent implements OnInit { - constructor(private ciphersService: CipherService, componentFactoryResolver: ComponentFactoryResolver) { - super(componentFactoryResolver); + constructor(private ciphersService: CipherService, componentFactoryResolver: ComponentFactoryResolver, + messagingService: MessagingService, userService: UserService) { + super(componentFactoryResolver, userService, messagingService, true); } - ngOnInit() { - this.load(); + async ngOnInit() { + if (await this.checkPremium()) { + await super.load(); + } } async setCiphers() { diff --git a/src/app/tools/weak-passwords-report.component.html b/src/app/tools/weak-passwords-report.component.html index 2b17138f10..9768cc5a78 100644 --- a/src/app/tools/weak-passwords-report.component.html +++ b/src/app/tools/weak-passwords-report.component.html @@ -10,7 +10,7 @@
-
+
{{'noWeakPasswords'}} diff --git a/src/app/tools/weak-passwords-report.component.ts b/src/app/tools/weak-passwords-report.component.ts index a356161c74..e9d4478588 100644 --- a/src/app/tools/weak-passwords-report.component.ts +++ b/src/app/tools/weak-passwords-report.component.ts @@ -5,7 +5,9 @@ import { } from '@angular/core'; import { CipherService } from 'jslib/abstractions/cipher.service'; +import { MessagingService } from 'jslib/abstractions/messaging.service'; import { PasswordGenerationService } from 'jslib/abstractions/passwordGeneration.service'; +import { UserService } from 'jslib/abstractions/user.service'; import { CipherView } from 'jslib/models/view/cipherView'; @@ -21,12 +23,15 @@ export class WeakPasswordsReportComponent extends CipherReportComponent implemen passwordStrengthMap = new Map(); constructor(private ciphersService: CipherService, private passwordGenerationService: PasswordGenerationService, - componentFactoryResolver: ComponentFactoryResolver) { - super(componentFactoryResolver); + componentFactoryResolver: ComponentFactoryResolver, messagingService: MessagingService, + userService: UserService) { + super(componentFactoryResolver, userService, messagingService, true); } - ngOnInit() { - this.load(); + async ngOnInit() { + if (await this.checkPremium()) { + await super.load(); + } } async setCiphers() {