mirror of
https://github.com/bitwarden/android.git
synced 2026-06-03 11:16:40 -05:00
Handle null or blank auth urls for Duo 2FA (#1044)
This commit is contained in:
committed by
Álison Fernandes
parent
8eafb8e180
commit
2e2b80470c
@@ -32,14 +32,13 @@ val GetTokenResponseJson.TwoFactorRequired?.preferredAuthMethod: TwoFactorAuthMe
|
||||
/**
|
||||
* If it exists, return the value of the Duo auth url.
|
||||
*/
|
||||
val GetTokenResponseJson.TwoFactorRequired?.twoFactorDuoAuthUrl: String
|
||||
val GetTokenResponseJson.TwoFactorRequired?.twoFactorDuoAuthUrl: String?
|
||||
get() = this
|
||||
?.authMethodsData
|
||||
?.duo
|
||||
?.get("AuthUrl")
|
||||
?.jsonPrimitive
|
||||
?.contentOrNull
|
||||
.orEmpty()
|
||||
|
||||
/**
|
||||
* If it exists, return the value to display for the email used with two-factor authentication.
|
||||
|
||||
@@ -160,10 +160,19 @@ class TwoFactorLoginViewModel @Inject constructor(
|
||||
*/
|
||||
private fun handleContinueButtonClick() {
|
||||
if (state.authMethod.isDuo) {
|
||||
val authUrl = authRepository.twoFactorResponse.twoFactorDuoAuthUrl
|
||||
// The url should not be empty unless the environment is somehow not supported.
|
||||
sendEvent(
|
||||
event = TwoFactorLoginEvent.NavigateToDuo(
|
||||
uri = Uri.parse(authRepository.twoFactorResponse.twoFactorDuoAuthUrl),
|
||||
),
|
||||
event = authUrl
|
||||
?.let {
|
||||
TwoFactorLoginEvent.NavigateToDuo(
|
||||
uri = Uri.parse(it),
|
||||
)
|
||||
}
|
||||
?: TwoFactorLoginEvent.ShowToast(
|
||||
// TODO BIT-1927 Update to use string resource
|
||||
message = "Duo not yet supported".asText(),
|
||||
),
|
||||
)
|
||||
} else {
|
||||
initiateLogin()
|
||||
|
||||
Reference in New Issue
Block a user