mirror of
https://github.com/bitwarden/browser
synced 2025-12-16 00:03:56 +00:00
Fix migration to Key Connector in cli commands (#616)
* Move CLI Key Connector check out of base class * Add missing await * Move safe operation out of try/catch block * Move Key Connector migration check to unlock command * Set convertAccountRequired flag in syncService * Remove unneeded service
This commit is contained in:
@@ -33,7 +33,7 @@ export class KeyConnectorService implements KeyConnectorServiceAbstraction {
|
||||
}
|
||||
|
||||
async userNeedsMigration() {
|
||||
const loggedInUsingSso = this.tokenService.getIsExternal();
|
||||
const loggedInUsingSso = await this.tokenService.getIsExternal();
|
||||
const requiredByOrganization = (await this.getManagingOrganization()) != null;
|
||||
const userIsNotUsingKeyConnector = !(await this.getUsesKeyConnector());
|
||||
|
||||
@@ -43,9 +43,9 @@ export class KeyConnectorService implements KeyConnectorServiceAbstraction {
|
||||
async migrateUser() {
|
||||
const organization = await this.getManagingOrganization();
|
||||
const key = await this.cryptoService.getKey();
|
||||
const keyConnectorRequest = new KeyConnectorUserKeyRequest(key.encKeyB64);
|
||||
|
||||
try {
|
||||
const keyConnectorRequest = new KeyConnectorUserKeyRequest(key.encKeyB64);
|
||||
await this.apiService.postUserKeyToKeyConnector(
|
||||
organization.keyConnectorUrl,
|
||||
keyConnectorRequest
|
||||
|
||||
@@ -334,6 +334,7 @@ export class SyncService implements SyncServiceAbstraction {
|
||||
]);
|
||||
|
||||
if (await this.keyConnectorService.userNeedsMigration()) {
|
||||
await this.keyConnectorService.setConvertAccountRequired(true);
|
||||
this.messagingService.send("convertAccountToKeyConnector");
|
||||
} else {
|
||||
this.keyConnectorService.removeConvertAccountRequired();
|
||||
|
||||
Reference in New Issue
Block a user