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.
@@ -49,6 +50,12 @@ interface LoginWizard {
4950 */
5051 suspend fun loginWithToken (loginToken : String ): Session
5152
53+ /* *
54+ * Login to the homeserver by sending a custom JsonDict.
55+ * The data should contain at least one entry "type" with a String value.
56+ */
57+ suspend fun loginCustom (data : JsonDict ): Session
58+
5259 /* *
5360 * Ask the homeserver to reset the user password. The password will not be reset until
5461 * [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
@@ -79,6 +80,14 @@ internal class DefaultLoginWizard(
7980 return sessionCreator.createSession(credentials, pendingSessionData.homeServerConnectionConfig)
8081 }
8182
83+ override suspend fun loginCustom (data : JsonDict ): Session {
84+ val credentials = executeRequest(null ) {
85+ authAPI.login(data)
86+ }
87+
88+ return sessionCreator.createSession(credentials, pendingSessionData.homeServerConnectionConfig)
89+ }
90+
8291 override suspend fun resetPassword (email : String , newPassword : String ) {
8392 val param = RegisterAddThreePidTask .Params (
8493 RegisterThreePid .Email (email),
You can’t perform that action at this time.
0 commit comments