From e05fd25198ad3ac843cc8f14fb1445364508b799 Mon Sep 17 00:00:00 2001 From: Thomas Rittson Date: Mon, 20 Dec 2021 09:29:03 +1000 Subject: [PATCH] Remove email from processTokenResponse args --- common/src/services/auth.service.ts | 7 +------ spec/common/services/auth.service.spec.ts | 25 +++++++++++------------ 2 files changed, 13 insertions(+), 19 deletions(-) diff --git a/common/src/services/auth.service.ts b/common/src/services/auth.service.ts index d60fc514..121d2e65 100644 --- a/common/src/services/auth.service.ts +++ b/common/src/services/auth.service.ts @@ -86,7 +86,6 @@ export class AuthService implements AuthServiceAbstraction { const result = await this.processTokenResponse( response, - email, localHashedPassword, null, null, @@ -124,7 +123,6 @@ export class AuthService implements AuthServiceAbstraction { const result = await this.processTokenResponse( response, null, - null, code, null, null, @@ -159,7 +157,6 @@ export class AuthService implements AuthServiceAbstraction { response, null, null, - null, clientId, clientSecret, null, @@ -179,7 +176,6 @@ export class AuthService implements AuthServiceAbstraction { return await this.processTokenResponse( response, - (this.savedTokenRequest as PasswordTokenRequest).email, this.localMasterPasswordHash, (this.savedTokenRequest as SsoTokenRequest).code, (this.savedTokenRequest as ApiTokenRequest).clientId, @@ -229,7 +225,6 @@ export class AuthService implements AuthServiceAbstraction { private async processTokenResponse( response: IdentityTokenResponse | IdentityTwoFactorResponse | IdentityCaptchaResponse, - email: string, localHashedPassword: string, code: string, clientId: string, @@ -258,7 +253,7 @@ export class AuthService implements AuthServiceAbstraction { this.saveAccountInformation(tokenResponse, clientId, clientSecret); if (tokenResponse.twoFactorToken != null) { - await this.tokenService.setTwoFactorToken(tokenResponse.twoFactorToken, email); + await this.tokenService.setTwoFactorToken(tokenResponse.twoFactorToken); } if (this.setCryptoKeys) { diff --git a/spec/common/services/auth.service.spec.ts b/spec/common/services/auth.service.spec.ts index a218e872..241262ab 100644 --- a/spec/common/services/auth.service.spec.ts +++ b/spec/common/services/auth.service.spec.ts @@ -186,7 +186,7 @@ describe("Cipher Service", () => { commonSetup(); const tokenResponse = newTokenResponse(); - tokenService.getTwoFactorToken(email).resolves(null); + tokenService.getTwoFactorToken().resolves(null); apiService.postIdentityToken(Arg.any()).resolves(tokenResponse); const expected = newAuthResponse(); @@ -221,7 +221,7 @@ describe("Cipher Service", () => { apiService.didNotReceive().postAccountKeys(Arg.any()); // Did not generate new private key pair keyConnectorService.didNotReceive().getAndSetKey(Arg.any()); // Did not fetch Key Connector key apiService.didNotReceive().postUserKeyToKeyConnector(Arg.any(), Arg.any()); // Did not send key to KC - tokenService.didNotReceive().setTwoFactorToken(Arg.any(), Arg.any()); // Did not save 2FA token + tokenService.didNotReceive().setTwoFactorToken(Arg.any()); // Did not save 2FA token // Return result: expect(result).toEqual(expected); @@ -235,7 +235,7 @@ describe("Cipher Service", () => { const tokenResponse = newTokenResponse(); (tokenResponse as any).siteKey = siteKey; - tokenService.getTwoFactorToken(email).resolves(null); + tokenService.getTwoFactorToken().resolves(null); apiService.postIdentityToken(Arg.any()).resolves(tokenResponse); const expected = new AuthResult(); @@ -255,7 +255,7 @@ describe("Cipher Service", () => { commonSetup(); const tokenResponse = newTokenResponse(); - tokenService.getTwoFactorToken(email).resolves(null); + tokenService.getTwoFactorToken().resolves(null); apiService.postIdentityToken(Arg.any()).resolves(tokenResponse); // Re-init authService with setCryptoKeys = false @@ -292,7 +292,7 @@ describe("Cipher Service", () => { const tokenResponse = newTokenResponse(); tokenResponse.privateKey = null; - tokenService.getTwoFactorToken(email).resolves(null); + tokenService.getTwoFactorToken().resolves(null); apiService.postIdentityToken(Arg.any()).resolves(tokenResponse); const result = await authService.logIn(email, masterPassword); @@ -311,7 +311,7 @@ describe("Cipher Service", () => { const tokenResponse = newTokenResponse(); (tokenResponse as any).twoFactorProviders2 = twoFactorProviders; - tokenService.getTwoFactorToken(email).resolves(null); + tokenService.getTwoFactorToken().resolves(null); apiService.postIdentityToken(Arg.any()).resolves(tokenResponse); const expected = new AuthResult(); @@ -331,7 +331,7 @@ describe("Cipher Service", () => { commonSetup(); logInSetup(); - tokenService.getTwoFactorToken(email).resolves(twoFactorToken); + tokenService.getTwoFactorToken().resolves(twoFactorToken); await authService.logIn(email, masterPassword); @@ -385,7 +385,6 @@ describe("Cipher Service", () => { } as DeviceRequest); (authService as any).localMasterPasswordHash = localHashedPassword; - (authService as any).email = email; (authService as any).savedTokenRequest = tokenRequest; await authService.logInTwoFactor({ @@ -416,7 +415,7 @@ describe("Cipher Service", () => { commonSetup(); const tokenResponse = newTokenResponse(); - tokenService.getTwoFactorToken(null).resolves(null); + tokenService.getTwoFactorToken().resolves(null); apiService.postIdentityToken(Arg.any()).resolves(tokenResponse); const result = await authService.logInSso(ssoCode, ssoCodeVerifier, ssoRedirectUrl, ssoOrgId); @@ -450,7 +449,7 @@ describe("Cipher Service", () => { apiService.didNotReceive().postAccountKeys(Arg.any()); // Did not generate new private key pair keyConnectorService.didNotReceive().getAndSetKey(Arg.any()); // Did not fetch Key Connector key apiService.didNotReceive().postUserKeyToKeyConnector(Arg.any(), Arg.any()); // Did not send key to KC - tokenService.didNotReceive().setTwoFactorToken(Arg.any(), Arg.any()); // Did not save 2FA token + tokenService.didNotReceive().setTwoFactorToken(Arg.any()); // Did not save 2FA token // Return result: const expected = newAuthResponse(); @@ -462,7 +461,7 @@ describe("Cipher Service", () => { const tokenResponse = newTokenResponse(); tokenResponse.key = null; - tokenService.getTwoFactorToken(null).resolves(null); + tokenService.getTwoFactorToken().resolves(null); apiService.postIdentityToken(Arg.any()).resolves(tokenResponse); const result = await authService.logInSso(ssoCode, ssoCodeVerifier, ssoRedirectUrl, ssoOrgId); @@ -538,7 +537,7 @@ describe("Cipher Service", () => { it("logInApi: user can login with api key", async () => { commonSetup(); - tokenService.getTwoFactorToken(Arg.any()).resolves(null); + tokenService.getTwoFactorToken().resolves(null); const tokenResponse = newTokenResponse(); apiService.postIdentityToken(Arg.any()).resolves(tokenResponse); @@ -590,7 +589,7 @@ describe("Cipher Service", () => { apiService.didNotReceive().postAccountKeys(Arg.any()); // Did not generate new private key pair keyConnectorService.didNotReceive().getAndSetKey(Arg.any()); // Did not fetch Key Connector key apiService.didNotReceive().postUserKeyToKeyConnector(Arg.any(), Arg.any()); // Did not send key to KC - tokenService.didNotReceive().setTwoFactorToken(Arg.any(), Arg.any()); // Did not save 2FA token + tokenService.didNotReceive().setTwoFactorToken(Arg.any()); // Did not save 2FA token // Return result: const expected = newAuthResponse();