Unverified Commit 2b9e7144 authored by Rafael Kellermann Streit's avatar Rafael Kellermann Streit Committed by GitHub

Merge pull request #1728 from RocketChat/fix/two-fa-with-email

[FIX] Two factor authentication when using email.
parents 6ba304a0 ebffae91
...@@ -17,12 +17,14 @@ import chat.rocket.android.server.domain.wideTile ...@@ -17,12 +17,14 @@ import chat.rocket.android.server.domain.wideTile
import chat.rocket.android.server.infraestructure.RocketChatClientFactory import chat.rocket.android.server.infraestructure.RocketChatClientFactory
import chat.rocket.android.util.extension.launchUI import chat.rocket.android.util.extension.launchUI
import chat.rocket.android.util.extensions.avatarUrl import chat.rocket.android.util.extensions.avatarUrl
import chat.rocket.android.util.extensions.isEmail
import chat.rocket.android.util.extensions.serverLogoUrl import chat.rocket.android.util.extensions.serverLogoUrl
import chat.rocket.android.util.retryIO import chat.rocket.android.util.retryIO
import chat.rocket.common.RocketChatAuthException import chat.rocket.common.RocketChatAuthException
import chat.rocket.common.RocketChatException import chat.rocket.common.RocketChatException
import chat.rocket.common.util.ifNull import chat.rocket.common.util.ifNull
import chat.rocket.core.internal.rest.login import chat.rocket.core.internal.rest.login
import chat.rocket.core.internal.rest.loginWithEmail
import chat.rocket.core.internal.rest.me import chat.rocket.core.internal.rest.me
import chat.rocket.core.model.Myself import chat.rocket.core.model.Myself
import javax.inject.Inject import javax.inject.Inject
...@@ -64,7 +66,11 @@ class TwoFAPresenter @Inject constructor( ...@@ -64,7 +66,11 @@ class TwoFAPresenter @Inject constructor(
try { try {
// The token is saved via the client TokenProvider // The token is saved via the client TokenProvider
val token = retryIO("login") { val token = retryIO("login") {
client.login(usernameOrEmail, password, twoFactorAuthenticationCode) if (usernameOrEmail.isEmail()) {
client.loginWithEmail(usernameOrEmail, password, twoFactorAuthenticationCode)
} else {
client.login(usernameOrEmail, password, twoFactorAuthenticationCode)
}
} }
val me = retryIO("me") { client.me() } val me = retryIO("me") { client.me() }
saveAccount(me) saveAccount(me)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment