1
0
mirror of https://github.com/bitwarden/browser.git synced 2025-02-19 01:51:27 +01:00

premium checks on reports

This commit is contained in:
Kyle Spearrin 2018-12-12 09:29:51 -05:00
parent 93c291dba1
commit cb953eda61
9 changed files with 71 additions and 23 deletions

View File

@ -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<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() {
this.ciphers = [];
}

View File

@ -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<string, number>();
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() {

View File

@ -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<string, string>();
cipherDocs = new Map<string, string>();
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() {

View File

@ -10,7 +10,7 @@
<div *ngIf="!hasLoaded && loading">
<i class="fa fa-spinner fa-spin text-muted" title="{{'loading' | i18n}}"></i>
</div>
<div class="mt-4" *ngIf="!loading">
<div class="mt-4" *ngIf="hasLoaded">
<app-callout type="success" title="{{'goodNews' | i18n}}" *ngIf="!ciphers.length">
{{'noReusedPasswords'}}
</app-callout>

View File

@ -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<string, number>;
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() {

View File

@ -10,7 +10,7 @@
<div *ngIf="!hasLoaded && loading">
<i class="fa fa-spinner fa-spin text-muted" title="{{'loading' | i18n}}"></i>
</div>
<div class="mt-4" *ngIf="!loading">
<div class="mt-4" *ngIf="hasLoaded">
<app-callout type="success" title="{{'goodNews' | i18n}}" *ngIf="!ciphers.length">
{{'noUnsecuredWebsites'}}
</app-callout>

View File

@ -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() {

View File

@ -10,7 +10,7 @@
<div *ngIf="!hasLoaded && loading">
<i class="fa fa-spinner fa-spin text-muted" title="{{'loading' | i18n}}"></i>
</div>
<div class="mt-4" *ngIf="!loading">
<div class="mt-4" *ngIf="hasLoaded">
<app-callout type="success" title="{{'goodNews' | i18n}}" *ngIf="!ciphers.length">
{{'noWeakPasswords'}}
</app-callout>

View File

@ -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<string, [string, string]>();
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() {