mirror of
https://github.com/bitwarden/jslib
synced 2025-12-06 00:03:29 +00:00
[EC-178] Logout on Key Connector error (#816)
This commit is contained in:
@@ -218,11 +218,13 @@ export class SsoComponent {
|
|||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
this.logService.error(e);
|
this.logService.error(e);
|
||||||
if (e.message === "Unable to reach key connector") {
|
|
||||||
|
// TODO: Key Connector Service should pass this error message to the logout callback instead of displaying here
|
||||||
|
if (e.message === "Key Connector error") {
|
||||||
this.platformUtilsService.showToast(
|
this.platformUtilsService.showToast(
|
||||||
"error",
|
"error",
|
||||||
null,
|
null,
|
||||||
this.i18nService.t("ssoKeyConnectorUnavailable")
|
this.i18nService.t("ssoKeyConnectorError")
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -399,6 +399,7 @@ export const SYSTEM_LANGUAGE = new InjectionToken<string>("SYSTEM_LANGUAGE");
|
|||||||
LogService,
|
LogService,
|
||||||
OrganizationServiceAbstraction,
|
OrganizationServiceAbstraction,
|
||||||
CryptoFunctionServiceAbstraction,
|
CryptoFunctionServiceAbstraction,
|
||||||
|
LOGOUT_CALLBACK,
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -22,7 +22,8 @@ export class KeyConnectorService implements KeyConnectorServiceAbstraction {
|
|||||||
private tokenService: TokenService,
|
private tokenService: TokenService,
|
||||||
private logService: LogService,
|
private logService: LogService,
|
||||||
private organizationService: OrganizationService,
|
private organizationService: OrganizationService,
|
||||||
private cryptoFunctionService: CryptoFunctionService
|
private cryptoFunctionService: CryptoFunctionService,
|
||||||
|
private logoutCallback: (expired: boolean, userId?: string) => void
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
setUsesKeyConnector(usesKeyConnector: boolean) {
|
setUsesKeyConnector(usesKeyConnector: boolean) {
|
||||||
@@ -52,7 +53,7 @@ export class KeyConnectorService implements KeyConnectorServiceAbstraction {
|
|||||||
keyConnectorRequest
|
keyConnectorRequest
|
||||||
);
|
);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
throw new Error("Unable to reach key connector");
|
this.handleKeyConnectorError(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
await this.apiService.postConvertToKeyConnector();
|
await this.apiService.postConvertToKeyConnector();
|
||||||
@@ -65,8 +66,7 @@ export class KeyConnectorService implements KeyConnectorServiceAbstraction {
|
|||||||
const k = new SymmetricCryptoKey(keyArr);
|
const k = new SymmetricCryptoKey(keyArr);
|
||||||
await this.cryptoService.setKey(k);
|
await this.cryptoService.setKey(k);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
this.logService.error(e);
|
this.handleKeyConnectorError(e);
|
||||||
throw new Error("Unable to reach key connector");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -102,7 +102,7 @@ export class KeyConnectorService implements KeyConnectorServiceAbstraction {
|
|||||||
try {
|
try {
|
||||||
await this.apiService.postUserKeyToKeyConnector(keyConnectorUrl, keyConnectorRequest);
|
await this.apiService.postUserKeyToKeyConnector(keyConnectorUrl, keyConnectorRequest);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
throw new Error("Unable to reach key connector");
|
this.handleKeyConnectorError(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
const keys = new KeysRequest(pubKey, privKey.encryptedString);
|
const keys = new KeysRequest(pubKey, privKey.encryptedString);
|
||||||
@@ -131,4 +131,12 @@ export class KeyConnectorService implements KeyConnectorServiceAbstraction {
|
|||||||
async clear() {
|
async clear() {
|
||||||
await this.removeConvertAccountRequired();
|
await this.removeConvertAccountRequired();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private handleKeyConnectorError(e: any) {
|
||||||
|
this.logService.error(e);
|
||||||
|
if (this.logoutCallback != null) {
|
||||||
|
this.logoutCallback(false);
|
||||||
|
}
|
||||||
|
throw new Error("Key Connector error");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user