1
0
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:
Thomas Rittson
2022-01-20 19:28:48 +10:00
committed by GitHub
parent ccd715d7b8
commit 9737c829f3
3 changed files with 4 additions and 78 deletions

View File

@@ -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

View File

@@ -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();