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

48 lines
1.6 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-14 20:42:04 +01:00
import { CipherView } from 'jslib/models/view/cipherView';
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-14 20:42:04 +01:00
constructor(protected cipherService: CipherService, componentFactoryResolver: ComponentFactoryResolver,
2018-12-12 15:29:51 +01:00
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() {
2018-12-14 19:56:01 +01:00
if (await this.checkAccess()) {
2018-12-12 15:29:51 +01:00
await super.load();
}
2018-12-11 21:11:16 +01:00
}
2018-12-12 15:11:10 +01:00
async setCiphers() {
2018-12-14 20:42:04 +01:00
const allCiphers = await this.getAllCiphers();
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;
}
2019-01-17 16:47:03 +01:00
return c.login.uris.some((u) => u.uri != null && u.uri.indexOf('http://') === 0);
2018-12-11 21:11:16 +01:00
});
2018-12-11 21:16:45 +01:00
this.ciphers = unsecuredCiphers;
2018-12-11 21:11:16 +01:00
}
2018-12-14 20:42:04 +01:00
protected getAllCiphers(): Promise<CipherView[]> {
return this.cipherService.getAllDecrypted();
}
2018-12-11 21:11:16 +01:00
}