mirror of
https://github.com/bitwarden/browser
synced 2025-12-15 07:43:35 +00:00
[PM-6727] Part 1: pass userId in login strategies (#9030)
* add validation to initAccount * pass userId to setMasterKey * fix key connector tests
This commit is contained in:
@@ -771,6 +771,19 @@ export class CryptoService implements CryptoServiceAbstraction {
|
||||
publicKey: string;
|
||||
privateKey: EncString;
|
||||
}> {
|
||||
// Verify keys don't exist
|
||||
const existingUserKey = await this.getUserKey();
|
||||
const existingPrivateKey = await this.getPrivateKey();
|
||||
if (existingUserKey != null || existingPrivateKey != null) {
|
||||
if (existingUserKey != null) {
|
||||
this.logService.error("Tried to initialize account with existing user key.");
|
||||
}
|
||||
if (existingPrivateKey != null) {
|
||||
this.logService.error("Tried to initialize account with existing private key.");
|
||||
}
|
||||
throw new Error("Cannot initialize account, keys already exist.");
|
||||
}
|
||||
|
||||
const userKey = (await this.keyGenerationService.createKey(512)) as UserKey;
|
||||
const [publicKey, privateKey] = await this.makeKeyPair(userKey);
|
||||
await this.setUserKey(userKey);
|
||||
|
||||
Reference in New Issue
Block a user