1
0
mirror of https://github.com/bitwarden/browser.git synced 2025-01-24 21:41:33 +01:00

expose email on init

This commit is contained in:
Kyle Spearrin 2019-01-07 23:30:04 -05:00
parent f3f17138c8
commit 65bd33d860

View File

@ -1,3 +1,4 @@
import { OnInit } from '@angular/core';
import { Router } from '@angular/router'; import { Router } from '@angular/router';
import { CryptoService } from '../../abstractions/crypto.service'; import { CryptoService } from '../../abstractions/crypto.service';
@ -6,9 +7,10 @@ import { MessagingService } from '../../abstractions/messaging.service';
import { PlatformUtilsService } from '../../abstractions/platformUtils.service'; import { PlatformUtilsService } from '../../abstractions/platformUtils.service';
import { UserService } from '../../abstractions/user.service'; import { UserService } from '../../abstractions/user.service';
export class LockComponent { export class LockComponent implements OnInit {
masterPassword: string = ''; masterPassword: string = '';
showPassword: boolean = false; showPassword: boolean = false;
email: string;
protected successRoute: string = 'vault'; protected successRoute: string = 'vault';
protected onSuccessfulSubmit: () => void; protected onSuccessfulSubmit: () => void;
@ -17,6 +19,10 @@ export class LockComponent {
protected platformUtilsService: PlatformUtilsService, protected messagingService: MessagingService, protected platformUtilsService: PlatformUtilsService, protected messagingService: MessagingService,
protected userService: UserService, protected cryptoService: CryptoService) { } protected userService: UserService, protected cryptoService: CryptoService) { }
async ngOnInit() {
this.email = await this.userService.getEmail();
}
async submit() { async submit() {
if (this.masterPassword == null || this.masterPassword === '') { if (this.masterPassword == null || this.masterPassword === '') {
this.platformUtilsService.showToast('error', this.i18nService.t('errorOccurred'), this.platformUtilsService.showToast('error', this.i18nService.t('errorOccurred'),
@ -24,10 +30,9 @@ export class LockComponent {
return; return;
} }
const email = await this.userService.getEmail();
const kdf = await this.userService.getKdf(); const kdf = await this.userService.getKdf();
const kdfIterations = await this.userService.getKdfIterations(); const kdfIterations = await this.userService.getKdfIterations();
const key = await this.cryptoService.makeKey(this.masterPassword, email, kdf, kdfIterations); const key = await this.cryptoService.makeKey(this.masterPassword, this.email, kdf, kdfIterations);
const keyHash = await this.cryptoService.hashPassword(this.masterPassword, key); const keyHash = await this.cryptoService.hashPassword(this.masterPassword, key);
const storedKeyHash = await this.cryptoService.getKeyHash(); const storedKeyHash = await this.cryptoService.getKeyHash();