From 897f5565b89ed0bffddd2be8791af0d8406d7bed Mon Sep 17 00:00:00 2001 From: Thomas Rittson Date: Thu, 16 Dec 2021 11:29:23 +1000 Subject: [PATCH] Extract createTokenRequest to new method --- common/src/services/auth.service.ts | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/common/src/services/auth.service.ts b/common/src/services/auth.service.ts index d359196f..6027ffbe 100644 --- a/common/src/services/auth.service.ts +++ b/common/src/services/auth.service.ts @@ -279,13 +279,12 @@ export class AuthService implements AuthServiceAbstraction { authingWithPassword(): boolean { return this.email != null && this.masterPasswordHash != null; } + private async createTokenRequest(email: string, hashedPassword: string, code: string, codeVerifier: string, redirectUrl: string, + clientId: string, clientSecret: string, twoFactorToken: string, twoFactorProvider: TwoFactorProviderType, remember: boolean, + captchaToken: string) { - private async logInHelper(email: string, hashedPassword: string, localHashedPassword: string, code: string, - codeVerifier: string, redirectUrl: string, clientId: string, clientSecret: string, key: SymmetricCryptoKey, - twoFactorProvider?: TwoFactorProviderType, twoFactorToken?: string, remember?: boolean, captchaToken?: string, - orgId?: string): Promise { - const storedTwoFactorToken = await this.tokenService.getTwoFactorToken(email); const appId = await this.appIdService.getAppId(); + const storedTwoFactorToken = await this.tokenService.getTwoFactorToken(email); const deviceRequest = new DeviceRequest(appId, this.platformUtilsService); let emailPassword: string[] = []; @@ -322,6 +321,17 @@ export class AuthService implements AuthServiceAbstraction { null, false, captchaToken, deviceRequest); } + return request; + } + + private async logInHelper(email: string, hashedPassword: string, localHashedPassword: string, code: string, + codeVerifier: string, redirectUrl: string, clientId: string, clientSecret: string, key: SymmetricCryptoKey, + twoFactorProvider?: TwoFactorProviderType, twoFactorToken?: string, remember?: boolean, captchaToken?: string, + orgId?: string): Promise { + + const request = await this.createTokenRequest(email, hashedPassword, code, codeVerifier, redirectUrl, + clientId, clientSecret, twoFactorToken, twoFactorProvider, remember, captchaToken); + const response = await this.apiService.postIdentityToken(request); this.clearState();