1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-11-27 12:36:14 +01:00

updateKey helper

This commit is contained in:
Kyle Spearrin 2018-11-14 16:22:57 -05:00
parent 6d8b156455
commit 9b43ccbbc0

View File

@ -102,9 +102,7 @@ export class ChangePasswordComponent implements OnInit {
try { try {
if (this.rotateEncKey) { if (this.rotateEncKey) {
this.formPromise = this.apiService.postPassword(request).then(() => { this.formPromise = this.apiService.postPassword(request).then(() => {
return this.makeRequest(newKey, request.newMasterPasswordHash); return this.updateKey(newKey, request.newMasterPasswordHash);
}).then((updateKeyRequest) => {
return this.apiService.postAccountKey(updateKeyRequest);
}); });
} else { } else {
this.formPromise = this.apiService.postPassword(request); this.formPromise = this.apiService.postPassword(request);
@ -171,7 +169,7 @@ export class ChangePasswordComponent implements OnInit {
return userInput; return userInput;
} }
private async makeRequest(key: SymmetricCryptoKey, masterPasswordHash: string): Promise<UpdateKeyRequest> { private async updateKey(key: SymmetricCryptoKey, masterPasswordHash: string) {
const encKey = await this.cryptoService.makeEncKey(key); const encKey = await this.cryptoService.makeEncKey(key);
const privateKey = await this.cryptoService.getPrivateKey(); const privateKey = await this.cryptoService.getPrivateKey();
let encPrivateKey: CipherString = null; let encPrivateKey: CipherString = null;
@ -202,6 +200,6 @@ export class ChangePasswordComponent implements OnInit {
request.ciphers.push(new CipherWithIdRequest(cipher)); request.ciphers.push(new CipherWithIdRequest(cipher));
} }
return request; await this.apiService.postAccountKey(request);
} }
} }