1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-11-06 09:20:43 +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 {
if (this.rotateEncKey) {
this.formPromise = this.apiService.postPassword(request).then(() => {
return this.makeRequest(newKey, request.newMasterPasswordHash);
}).then((updateKeyRequest) => {
return this.apiService.postAccountKey(updateKeyRequest);
return this.updateKey(newKey, request.newMasterPasswordHash);
});
} else {
this.formPromise = this.apiService.postPassword(request);
@ -171,7 +169,7 @@ export class ChangePasswordComponent implements OnInit {
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 privateKey = await this.cryptoService.getPrivateKey();
let encPrivateKey: CipherString = null;
@ -202,6 +200,6 @@ export class ChangePasswordComponent implements OnInit {
request.ciphers.push(new CipherWithIdRequest(cipher));
}
return request;
await this.apiService.postAccountKey(request);
}
}