mirror of
https://github.com/bitwarden/web
synced 2025-12-10 13:23:15 +00:00
premium checks on reports
This commit is contained in:
@@ -9,6 +9,9 @@ import { CipherView } from 'jslib/models/view/cipherView';
|
|||||||
import { ModalComponent } from '../modal.component';
|
import { ModalComponent } from '../modal.component';
|
||||||
import { AddEditComponent } from '../vault/add-edit.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 {
|
export class CipherReportComponent {
|
||||||
@ViewChild('cipherAddEdit', { read: ViewContainerRef }) cipherAddEditModalRef: ViewContainerRef;
|
@ViewChild('cipherAddEdit', { read: ViewContainerRef }) cipherAddEditModalRef: ViewContainerRef;
|
||||||
|
|
||||||
@@ -18,7 +21,8 @@ export class CipherReportComponent {
|
|||||||
|
|
||||||
private modal: ModalComponent = null;
|
private modal: ModalComponent = null;
|
||||||
|
|
||||||
constructor(private componentFactoryResolver: ComponentFactoryResolver) { }
|
constructor(private componentFactoryResolver: ComponentFactoryResolver, protected userService: UserService,
|
||||||
|
protected messagingService: MessagingService, public requiresPremium: boolean) { }
|
||||||
|
|
||||||
async load() {
|
async load() {
|
||||||
this.loading = true;
|
this.loading = true;
|
||||||
@@ -54,6 +58,16 @@ export class CipherReportComponent {
|
|||||||
return childComponent;
|
return childComponent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected async checkPremium(): Promise<boolean> {
|
||||||
|
const accessPremium = await this.userService.canAccessPremium();
|
||||||
|
if (this.requiresPremium && !accessPremium) {
|
||||||
|
this.messagingService.send('premiumRequired');
|
||||||
|
this.loading = false;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
protected async setCiphers() {
|
protected async setCiphers() {
|
||||||
this.ciphers = [];
|
this.ciphers = [];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,13 @@
|
|||||||
import {
|
import {
|
||||||
Component,
|
Component,
|
||||||
ComponentFactoryResolver,
|
ComponentFactoryResolver,
|
||||||
|
OnInit,
|
||||||
} from '@angular/core';
|
} from '@angular/core';
|
||||||
|
|
||||||
import { AuditService } from 'jslib/abstractions/audit.service';
|
import { AuditService } from 'jslib/abstractions/audit.service';
|
||||||
import { CipherService } from 'jslib/abstractions/cipher.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';
|
import { CipherView } from 'jslib/models/view/cipherView';
|
||||||
|
|
||||||
@@ -16,12 +19,23 @@ import { CipherReportComponent } from './cipher-report.component';
|
|||||||
selector: 'app-exposed-passwords-report',
|
selector: 'app-exposed-passwords-report',
|
||||||
templateUrl: 'exposed-passwords-report.component.html',
|
templateUrl: 'exposed-passwords-report.component.html',
|
||||||
})
|
})
|
||||||
export class ExposedPasswordsReportComponent extends CipherReportComponent {
|
export class ExposedPasswordsReportComponent extends CipherReportComponent implements OnInit {
|
||||||
exposedPasswordMap = new Map<string, number>();
|
exposedPasswordMap = new Map<string, number>();
|
||||||
|
|
||||||
constructor(private ciphersService: CipherService, private auditService: AuditService,
|
constructor(private ciphersService: CipherService, private auditService: AuditService,
|
||||||
componentFactoryResolver: ComponentFactoryResolver) {
|
componentFactoryResolver: ComponentFactoryResolver, messagingService: MessagingService,
|
||||||
super(componentFactoryResolver);
|
userService: UserService) {
|
||||||
|
super(componentFactoryResolver, userService, messagingService, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
ngOnInit() {
|
||||||
|
this.checkPremium();
|
||||||
|
}
|
||||||
|
|
||||||
|
async load() {
|
||||||
|
if (await this.checkPremium()) {
|
||||||
|
super.load();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async setCiphers() {
|
async setCiphers() {
|
||||||
|
|||||||
@@ -5,6 +5,8 @@ import {
|
|||||||
} from '@angular/core';
|
} from '@angular/core';
|
||||||
|
|
||||||
import { CipherService } from 'jslib/abstractions/cipher.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';
|
import { CipherView } from 'jslib/models/view/cipherView';
|
||||||
|
|
||||||
@@ -22,12 +24,15 @@ export class InactiveTwoFactorReportComponent extends CipherReportComponent impl
|
|||||||
services = new Map<string, string>();
|
services = new Map<string, string>();
|
||||||
cipherDocs = new Map<string, string>();
|
cipherDocs = new Map<string, string>();
|
||||||
|
|
||||||
constructor(private ciphersService: CipherService, componentFactoryResolver: ComponentFactoryResolver) {
|
constructor(private ciphersService: CipherService, componentFactoryResolver: ComponentFactoryResolver,
|
||||||
super(componentFactoryResolver);
|
messagingService: MessagingService, userService: UserService) {
|
||||||
|
super(componentFactoryResolver, userService, messagingService, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit() {
|
async ngOnInit() {
|
||||||
this.load();
|
if (await this.checkPremium()) {
|
||||||
|
await super.load();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async setCiphers() {
|
async setCiphers() {
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
<div *ngIf="!hasLoaded && loading">
|
<div *ngIf="!hasLoaded && loading">
|
||||||
<i class="fa fa-spinner fa-spin text-muted" title="{{'loading' | i18n}}"></i>
|
<i class="fa fa-spinner fa-spin text-muted" title="{{'loading' | i18n}}"></i>
|
||||||
</div>
|
</div>
|
||||||
<div class="mt-4" *ngIf="!loading">
|
<div class="mt-4" *ngIf="hasLoaded">
|
||||||
<app-callout type="success" title="{{'goodNews' | i18n}}" *ngIf="!ciphers.length">
|
<app-callout type="success" title="{{'goodNews' | i18n}}" *ngIf="!ciphers.length">
|
||||||
{{'noReusedPasswords'}}
|
{{'noReusedPasswords'}}
|
||||||
</app-callout>
|
</app-callout>
|
||||||
|
|||||||
@@ -5,6 +5,8 @@ import {
|
|||||||
} from '@angular/core';
|
} from '@angular/core';
|
||||||
|
|
||||||
import { CipherService } from 'jslib/abstractions/cipher.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';
|
import { CipherView } from 'jslib/models/view/cipherView';
|
||||||
|
|
||||||
@@ -19,12 +21,15 @@ import { CipherReportComponent } from './cipher-report.component';
|
|||||||
export class ReusedPasswordsReportComponent extends CipherReportComponent implements OnInit {
|
export class ReusedPasswordsReportComponent extends CipherReportComponent implements OnInit {
|
||||||
passwordUseMap: Map<string, number>;
|
passwordUseMap: Map<string, number>;
|
||||||
|
|
||||||
constructor(private ciphersService: CipherService, componentFactoryResolver: ComponentFactoryResolver) {
|
constructor(private ciphersService: CipherService, componentFactoryResolver: ComponentFactoryResolver,
|
||||||
super(componentFactoryResolver);
|
messagingService: MessagingService, userService: UserService) {
|
||||||
|
super(componentFactoryResolver, userService, messagingService, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit() {
|
async ngOnInit() {
|
||||||
this.load();
|
if (await this.checkPremium()) {
|
||||||
|
await super.load();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async setCiphers() {
|
async setCiphers() {
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
<div *ngIf="!hasLoaded && loading">
|
<div *ngIf="!hasLoaded && loading">
|
||||||
<i class="fa fa-spinner fa-spin text-muted" title="{{'loading' | i18n}}"></i>
|
<i class="fa fa-spinner fa-spin text-muted" title="{{'loading' | i18n}}"></i>
|
||||||
</div>
|
</div>
|
||||||
<div class="mt-4" *ngIf="!loading">
|
<div class="mt-4" *ngIf="hasLoaded">
|
||||||
<app-callout type="success" title="{{'goodNews' | i18n}}" *ngIf="!ciphers.length">
|
<app-callout type="success" title="{{'goodNews' | i18n}}" *ngIf="!ciphers.length">
|
||||||
{{'noUnsecuredWebsites'}}
|
{{'noUnsecuredWebsites'}}
|
||||||
</app-callout>
|
</app-callout>
|
||||||
|
|||||||
@@ -5,6 +5,8 @@ import {
|
|||||||
} from '@angular/core';
|
} from '@angular/core';
|
||||||
|
|
||||||
import { CipherService } from 'jslib/abstractions/cipher.service';
|
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';
|
import { CipherType } from 'jslib/enums/cipherType';
|
||||||
|
|
||||||
@@ -15,12 +17,15 @@ import { CipherReportComponent } from './cipher-report.component';
|
|||||||
templateUrl: 'unsecured-websites-report.component.html',
|
templateUrl: 'unsecured-websites-report.component.html',
|
||||||
})
|
})
|
||||||
export class UnsecuredWebsitesReportComponent extends CipherReportComponent implements OnInit {
|
export class UnsecuredWebsitesReportComponent extends CipherReportComponent implements OnInit {
|
||||||
constructor(private ciphersService: CipherService, componentFactoryResolver: ComponentFactoryResolver) {
|
constructor(private ciphersService: CipherService, componentFactoryResolver: ComponentFactoryResolver,
|
||||||
super(componentFactoryResolver);
|
messagingService: MessagingService, userService: UserService) {
|
||||||
|
super(componentFactoryResolver, userService, messagingService, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit() {
|
async ngOnInit() {
|
||||||
this.load();
|
if (await this.checkPremium()) {
|
||||||
|
await super.load();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async setCiphers() {
|
async setCiphers() {
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
<div *ngIf="!hasLoaded && loading">
|
<div *ngIf="!hasLoaded && loading">
|
||||||
<i class="fa fa-spinner fa-spin text-muted" title="{{'loading' | i18n}}"></i>
|
<i class="fa fa-spinner fa-spin text-muted" title="{{'loading' | i18n}}"></i>
|
||||||
</div>
|
</div>
|
||||||
<div class="mt-4" *ngIf="!loading">
|
<div class="mt-4" *ngIf="hasLoaded">
|
||||||
<app-callout type="success" title="{{'goodNews' | i18n}}" *ngIf="!ciphers.length">
|
<app-callout type="success" title="{{'goodNews' | i18n}}" *ngIf="!ciphers.length">
|
||||||
{{'noWeakPasswords'}}
|
{{'noWeakPasswords'}}
|
||||||
</app-callout>
|
</app-callout>
|
||||||
|
|||||||
@@ -5,7 +5,9 @@ import {
|
|||||||
} from '@angular/core';
|
} from '@angular/core';
|
||||||
|
|
||||||
import { CipherService } from 'jslib/abstractions/cipher.service';
|
import { CipherService } from 'jslib/abstractions/cipher.service';
|
||||||
|
import { MessagingService } from 'jslib/abstractions/messaging.service';
|
||||||
import { PasswordGenerationService } from 'jslib/abstractions/passwordGeneration.service';
|
import { PasswordGenerationService } from 'jslib/abstractions/passwordGeneration.service';
|
||||||
|
import { UserService } from 'jslib/abstractions/user.service';
|
||||||
|
|
||||||
import { CipherView } from 'jslib/models/view/cipherView';
|
import { CipherView } from 'jslib/models/view/cipherView';
|
||||||
|
|
||||||
@@ -21,12 +23,15 @@ export class WeakPasswordsReportComponent extends CipherReportComponent implemen
|
|||||||
passwordStrengthMap = new Map<string, [string, string]>();
|
passwordStrengthMap = new Map<string, [string, string]>();
|
||||||
|
|
||||||
constructor(private ciphersService: CipherService, private passwordGenerationService: PasswordGenerationService,
|
constructor(private ciphersService: CipherService, private passwordGenerationService: PasswordGenerationService,
|
||||||
componentFactoryResolver: ComponentFactoryResolver) {
|
componentFactoryResolver: ComponentFactoryResolver, messagingService: MessagingService,
|
||||||
super(componentFactoryResolver);
|
userService: UserService) {
|
||||||
|
super(componentFactoryResolver, userService, messagingService, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit() {
|
async ngOnInit() {
|
||||||
this.load();
|
if (await this.checkPremium()) {
|
||||||
|
await super.load();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async setCiphers() {
|
async setCiphers() {
|
||||||
|
|||||||
Reference in New Issue
Block a user