File tree Expand file tree Collapse file tree 4 files changed +21
-0
lines changed
matrix-sdk-android/src/main/java/org/matrix/android/sdk Expand file tree Collapse file tree 4 files changed +21
-0
lines changed Original file line number Diff line number Diff line change 1+ Add API `LoginWizard.loginCustom(data: JsonDict): Session` to be able to login to a homeserver using arbitrary request content
Original file line number Diff line number Diff line change 1717package org.matrix.android.sdk.api.auth.login
1818
1919import org.matrix.android.sdk.api.session.Session
20+ import org.matrix.android.sdk.api.util.JsonDict
2021
2122/* *
2223 * Set of methods to be able to login to an existing account on a homeserver.
@@ -51,6 +52,12 @@ interface LoginWizard {
5152 */
5253 suspend fun loginWithToken (loginToken : String ): Session
5354
55+ /* *
56+ * Login to the homeserver by sending a custom JsonDict.
57+ * The data should contain at least one entry "type" with a String value.
58+ */
59+ suspend fun loginCustom (data : JsonDict ): Session
60+
5461 /* *
5562 * Ask the homeserver to reset the user password. The password will not be reset until
5663 * [resetPasswordMailConfirmed] is successfully called.
Original file line number Diff line number Diff line change @@ -121,6 +121,10 @@ internal interface AuthAPI {
121121 @POST(NetworkConstants .URI_API_PREFIX_PATH_R0 + " login" )
122122 suspend fun login (@Body loginParams : TokenLoginParams ): Credentials
123123
124+ @Headers(" CONNECT_TIMEOUT:60000" , " READ_TIMEOUT:60000" , " WRITE_TIMEOUT:60000" )
125+ @POST(NetworkConstants .URI_API_PREFIX_PATH_R0 + " login" )
126+ suspend fun login (@Body loginParams : JsonDict ): Credentials
127+
124128 /* *
125129 * Ask the homeserver to reset the password associated with the provided email.
126130 */
Original file line number Diff line number Diff line change @@ -21,6 +21,7 @@ import org.matrix.android.sdk.api.auth.login.LoginProfileInfo
2121import org.matrix.android.sdk.api.auth.login.LoginWizard
2222import org.matrix.android.sdk.api.auth.registration.RegisterThreePid
2323import org.matrix.android.sdk.api.session.Session
24+ import org.matrix.android.sdk.api.util.JsonDict
2425import org.matrix.android.sdk.internal.auth.AuthAPI
2526import org.matrix.android.sdk.internal.auth.PendingSessionStore
2627import org.matrix.android.sdk.internal.auth.SessionCreator
@@ -91,6 +92,14 @@ internal class DefaultLoginWizard(
9192 return sessionCreator.createSession(credentials, pendingSessionData.homeServerConnectionConfig)
9293 }
9394
95+ override suspend fun loginCustom (data : JsonDict ): Session {
96+ val credentials = executeRequest(null ) {
97+ authAPI.login(data)
98+ }
99+
100+ return sessionCreator.createSession(credentials, pendingSessionData.homeServerConnectionConfig)
101+ }
102+
94103 override suspend fun resetPassword (email : String , newPassword : String ) {
95104 val param = RegisterAddThreePidTask .Params (
96105 RegisterThreePid .Email (email),
You can’t perform that action at this time.
0 commit comments