bitwarden-estensione-browser/src/app/tools/unsecured-websites-report.c...

42 lines
1.4 KiB
TypeScript
Raw Normal View History

2018-12-11 21:11:16 +01:00
import {
Component,
ComponentFactoryResolver,
OnInit,
} from '@angular/core';
import { CipherService } from 'jslib/abstractions/cipher.service';
2018-12-12 15:29:51 +01:00
import { MessagingService } from 'jslib/abstractions/messaging.service';
import { UserService } from 'jslib/abstractions/user.service';
2018-12-11 21:11:16 +01:00
import { CipherType } from 'jslib/enums/cipherType';
2018-12-12 15:11:10 +01:00
import { CipherReportComponent } from './cipher-report.component';
2018-12-11 21:11:16 +01:00
@Component({
selector: 'app-unsecured-websites-report',
templateUrl: 'unsecured-websites-report.component.html',
})
2018-12-12 15:11:10 +01:00
export class UnsecuredWebsitesReportComponent extends CipherReportComponent implements OnInit {
2018-12-12 15:29:51 +01:00
constructor(private ciphersService: CipherService, componentFactoryResolver: ComponentFactoryResolver,
messagingService: MessagingService, userService: UserService) {
super(componentFactoryResolver, userService, messagingService, true);
2018-12-12 15:11:10 +01:00
}
2018-12-11 21:11:16 +01:00
2018-12-12 15:29:51 +01:00
async ngOnInit() {
if (await this.checkPremium()) {
await super.load();
}
2018-12-11 21:11:16 +01:00
}
2018-12-12 15:11:10 +01:00
async setCiphers() {
2018-12-11 21:11:16 +01:00
const allCiphers = await this.ciphersService.getAllDecrypted();
2018-12-11 21:16:45 +01:00
const unsecuredCiphers = allCiphers.filter((c) => {
2018-12-11 21:11:16 +01:00
if (c.type !== CipherType.Login || !c.login.hasUris) {
return false;
}
return c.login.uris.find((u) => u.uri.indexOf('http://') === 0) != null;
});
2018-12-11 21:16:45 +01:00
this.ciphers = unsecuredCiphers;
2018-12-11 21:11:16 +01:00
}
}