Commit ebffae91 authored by Filipe de Lima Brito's avatar Filipe de Lima Brito

Fix the two factor authentication when login with email address.

parent f6b95022
...@@ -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,8 +66,12 @@ class TwoFAPresenter @Inject constructor( ...@@ -64,8 +66,12 @@ 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") {
if (usernameOrEmail.isEmail()) {
client.loginWithEmail(usernameOrEmail, password, twoFactorAuthenticationCode)
} else {
client.login(usernameOrEmail, password, twoFactorAuthenticationCode) client.login(usernameOrEmail, password, twoFactorAuthenticationCode)
} }
}
val me = retryIO("me") { client.me() } val me = retryIO("me") { client.me() }
saveAccount(me) saveAccount(me)
saveCurrentServerInteractor.save(currentServer) saveCurrentServerInteractor.save(currentServer)
......
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