mirror of
https://github.com/bitwarden/jslib
synced 2025-12-10 13:23:15 +00:00
More descriptive arg names for processTokenResponse
This commit is contained in:
@@ -88,7 +88,7 @@ export class AuthService implements AuthServiceAbstraction {
|
|||||||
|
|
||||||
const response = await this.apiService.postIdentityToken(tokenRequest);
|
const response = await this.apiService.postIdentityToken(tokenRequest);
|
||||||
|
|
||||||
const result = await this.processTokenResponse(response, null);
|
const result = await this.processTokenResponse(response);
|
||||||
|
|
||||||
if (!!result.captchaSiteKey) {
|
if (!!result.captchaSiteKey) {
|
||||||
return result;
|
return result;
|
||||||
@@ -132,8 +132,10 @@ export class AuthService implements AuthServiceAbstraction {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const response = await this.apiService.postIdentityToken(tokenRequest);
|
const response = await this.apiService.postIdentityToken(tokenRequest);
|
||||||
|
const tokenResponse = response as IdentityTokenResponse;
|
||||||
|
|
||||||
const result = await this.processTokenResponse(response, code);
|
const newSsoUser = tokenResponse.key == null;
|
||||||
|
const result = await this.processTokenResponse(response, newSsoUser);
|
||||||
|
|
||||||
if (!!result.captchaSiteKey) {
|
if (!!result.captchaSiteKey) {
|
||||||
return result;
|
return result;
|
||||||
@@ -144,9 +146,8 @@ export class AuthService implements AuthServiceAbstraction {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
const tokenResponse = response as IdentityTokenResponse;
|
|
||||||
if (this.setCryptoKeys && tokenResponse.keyConnectorUrl != null) {
|
if (this.setCryptoKeys && tokenResponse.keyConnectorUrl != null) {
|
||||||
if (tokenResponse.key != null) {
|
if (!newSsoUser) {
|
||||||
// Existing SSO user that uses Key Connector
|
// Existing SSO user that uses Key Connector
|
||||||
await this.keyConnectorService.getAndSetKey(tokenResponse.keyConnectorUrl);
|
await this.keyConnectorService.getAndSetKey(tokenResponse.keyConnectorUrl);
|
||||||
} else {
|
} else {
|
||||||
@@ -186,7 +187,7 @@ export class AuthService implements AuthServiceAbstraction {
|
|||||||
|
|
||||||
const response = await this.apiService.postIdentityToken(tokenRequest);
|
const response = await this.apiService.postIdentityToken(tokenRequest);
|
||||||
|
|
||||||
const result = await this.processTokenResponse(response, null);
|
const result = await this.processTokenResponse(response);
|
||||||
|
|
||||||
if (!!result.captchaSiteKey) {
|
if (!!result.captchaSiteKey) {
|
||||||
return result;
|
return result;
|
||||||
@@ -265,7 +266,7 @@ export class AuthService implements AuthServiceAbstraction {
|
|||||||
|
|
||||||
private async processTokenResponse(
|
private async processTokenResponse(
|
||||||
response: IdentityTokenResponse | IdentityTwoFactorResponse | IdentityCaptchaResponse,
|
response: IdentityTokenResponse | IdentityTwoFactorResponse | IdentityCaptchaResponse,
|
||||||
code: string,
|
newSsoUser?: boolean,
|
||||||
): Promise<AuthResult> {
|
): Promise<AuthResult> {
|
||||||
this.clearState();
|
this.clearState();
|
||||||
const result = new AuthResult();
|
const result = new AuthResult();
|
||||||
@@ -291,7 +292,7 @@ export class AuthService implements AuthServiceAbstraction {
|
|||||||
await this.tokenService.setTwoFactorToken(tokenResponse.twoFactorToken);
|
await this.tokenService.setTwoFactorToken(tokenResponse.twoFactorToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.setCryptoKeys && !this.isNewSsoUser(code, tokenResponse.key)) {
|
if (this.setCryptoKeys && !newSsoUser) {
|
||||||
await this.cryptoService.setEncKey(tokenResponse.key);
|
await this.cryptoService.setEncKey(tokenResponse.key);
|
||||||
|
|
||||||
// User doesn't have a key pair yet (old account), let's generate one for them
|
// User doesn't have a key pair yet (old account), let's generate one for them
|
||||||
|
|||||||
Reference in New Issue
Block a user