From f15fd246a8d60e5494ec3b87fd583f821ff23172 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Bispo?= Date: Mon, 16 Jan 2023 18:25:44 +0000 Subject: [PATCH] Passwordless login 2FA not working (#2289) * [SG-174] Fix 2FA passwordless login * [SG-982] Enable login with device --- src/App/Pages/Accounts/LoginPageViewModel.cs | 3 +-- src/Core/Services/AuthService.cs | 9 ++++++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/App/Pages/Accounts/LoginPageViewModel.cs b/src/App/Pages/Accounts/LoginPageViewModel.cs index 1e781e7d4..ba04b1e4b 100644 --- a/src/App/Pages/Accounts/LoginPageViewModel.cs +++ b/src/App/Pages/Accounts/LoginPageViewModel.cs @@ -149,8 +149,7 @@ namespace Bit.App.Pages Email = await _stateService.GetRememberedEmailAsync(); } var deviceIdentifier = await _appIdService.GetAppIdAsync(); - // TODO uncomment to enable login with device - //IsKnownDevice = await _apiService.GetKnownDeviceAsync(Email, deviceIdentifier); + IsKnownDevice = await _apiService.GetKnownDeviceAsync(Email, deviceIdentifier); CanRemoveAccount = await _stateService.GetActiveUserEmailAsync() != Email; await _deviceActionService.HideLoadingAsync(); } diff --git a/src/Core/Services/AuthService.cs b/src/Core/Services/AuthService.cs index 91f633b37..4a6e82cb6 100644 --- a/src/Core/Services/AuthService.cs +++ b/src/Core/Services/AuthService.cs @@ -106,6 +106,7 @@ namespace Bit.Core.Services public string CaptchaToken { get; set; } public string MasterPasswordHash { get; set; } public string LocalMasterPasswordHash { get; set; } + public string AuthRequestId { get; set; } public string Code { get; set; } public string CodeVerifier { get; set; } public string SsoRedirectUrl { get; set; } @@ -163,7 +164,7 @@ namespace Bit.Core.Services CaptchaToken = captchaToken; } return LogInHelperAsync(Email, MasterPasswordHash, LocalMasterPasswordHash, Code, CodeVerifier, SsoRedirectUrl, _key, - twoFactorProvider, twoFactorToken, remember, CaptchaToken); + twoFactorProvider, twoFactorToken, remember, CaptchaToken, authRequestId: AuthRequestId); } public async Task LogInCompleteAsync(string email, string masterPassword, @@ -328,12 +329,12 @@ namespace Bit.Core.Services if (twoFactorToken != null && twoFactorProvider != null) { request = new TokenRequest(emailPassword, codeCodeVerifier, twoFactorProvider, twoFactorToken, remember, - captchaToken, deviceRequest); + captchaToken, deviceRequest, authRequestId); } else if (storedTwoFactorToken != null) { request = new TokenRequest(emailPassword, codeCodeVerifier, TwoFactorProviderType.Remember, - storedTwoFactorToken, false, captchaToken, deviceRequest); + storedTwoFactorToken, false, captchaToken, deviceRequest, authRequestId); } else if (authRequestId != null) { @@ -359,6 +360,7 @@ namespace Bit.Core.Services Email = email; MasterPasswordHash = hashedPassword; LocalMasterPasswordHash = localHashedPassword; + AuthRequestId = authRequestId; Code = code; CodeVerifier = codeVerifier; SsoRedirectUrl = redirectUrl; @@ -481,6 +483,7 @@ namespace Bit.Core.Services Email = null; CaptchaToken = null; MasterPasswordHash = null; + AuthRequestId = null; Code = null; CodeVerifier = null; SsoRedirectUrl = null;