mirror of
https://github.com/vector-im/element-android.git
synced 2024-11-15 01:35:07 +08:00
Allows authentication by email
This commit is contained in:
parent
2885b510ab
commit
b3fe742ec4
Binary file not shown.
@ -1,5 +1,6 @@
|
|||||||
package im.vector.matrix.android.internal.auth
|
package im.vector.matrix.android.internal.auth
|
||||||
|
|
||||||
|
import android.util.Patterns
|
||||||
import arrow.core.Either
|
import arrow.core.Either
|
||||||
import arrow.core.leftIfNull
|
import arrow.core.leftIfNull
|
||||||
import im.vector.matrix.android.api.MatrixCallback
|
import im.vector.matrix.android.api.MatrixCallback
|
||||||
@ -11,6 +12,7 @@ import im.vector.matrix.android.api.util.Cancelable
|
|||||||
import im.vector.matrix.android.internal.auth.data.Credentials
|
import im.vector.matrix.android.internal.auth.data.Credentials
|
||||||
import im.vector.matrix.android.internal.auth.data.PasswordLoginParams
|
import im.vector.matrix.android.internal.auth.data.PasswordLoginParams
|
||||||
import im.vector.matrix.android.internal.auth.data.SessionParams
|
import im.vector.matrix.android.internal.auth.data.SessionParams
|
||||||
|
import im.vector.matrix.android.internal.auth.data.ThreePidMedium
|
||||||
import im.vector.matrix.android.internal.network.executeRequest
|
import im.vector.matrix.android.internal.network.executeRequest
|
||||||
import im.vector.matrix.android.internal.session.DefaultSession
|
import im.vector.matrix.android.internal.session.DefaultSession
|
||||||
import im.vector.matrix.android.internal.util.CancelableCoroutine
|
import im.vector.matrix.android.internal.util.CancelableCoroutine
|
||||||
@ -53,7 +55,11 @@ class DefaultAuthenticator(private val retrofitBuilder: Retrofit.Builder,
|
|||||||
password: String): Either<Failure, Session> = withContext(coroutineDispatchers.io) {
|
password: String): Either<Failure, Session> = withContext(coroutineDispatchers.io) {
|
||||||
|
|
||||||
val authAPI = buildAuthAPI(homeServerConnectionConfig)
|
val authAPI = buildAuthAPI(homeServerConnectionConfig)
|
||||||
val loginParams = PasswordLoginParams.userIdentifier(login, password, "Mobile")
|
val loginParams = if (Patterns.EMAIL_ADDRESS.matcher(login).matches()) {
|
||||||
|
PasswordLoginParams.thirdPartyIdentifier(ThreePidMedium.EMAIL, login, password, "Mobile")
|
||||||
|
} else {
|
||||||
|
PasswordLoginParams.userIdentifier(login, password, "Mobile")
|
||||||
|
}
|
||||||
executeRequest<Credentials> {
|
executeRequest<Credentials> {
|
||||||
apiCall = authAPI.login(loginParams)
|
apiCall = authAPI.login(loginParams)
|
||||||
}.leftIfNull {
|
}.leftIfNull {
|
||||||
|
@ -0,0 +1,6 @@
|
|||||||
|
package im.vector.matrix.android.internal.auth.data
|
||||||
|
|
||||||
|
object ThreePidMedium {
|
||||||
|
const val EMAIL = "email"
|
||||||
|
const val MSISDN = "msisdn"
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user