Skip to content
Snippets Groups Projects
Commit 8dc64fac authored by Taras's avatar Taras
Browse files

Add refresh token to register

parent c2ccd5b1
No related branches found
No related tags found
No related merge requests found
...@@ -82,7 +82,7 @@ interface RegistrationWizard { ...@@ -82,7 +82,7 @@ interface RegistrationWizard {
* Current registration "session" param will be included into authParams by default. * Current registration "session" param will be included into authParams by default.
* The authParams should contain at least one entry "type" with a String value. * The authParams should contain at least one entry "type" with a String value.
*/ */
suspend fun registrationCustom(authParams: JsonDict, initialDeviceDisplayName: String? = null): RegistrationResult suspend fun registrationCustom(authParams: JsonDict, initialDeviceDisplayName: String? = null, useRefreshToken: Boolean = false): RegistrationResult
/** /**
* Perform the "m.login.email.identity" or "m.login.msisdn" stage. * Perform the "m.login.email.identity" or "m.login.msisdn" stage.
......
...@@ -54,12 +54,13 @@ internal class DefaultRegistrationWizard( ...@@ -54,12 +54,13 @@ internal class DefaultRegistrationWizard(
override fun getCurrentThreePid(): String? { override fun getCurrentThreePid(): String? {
return when (val threePid = pendingSessionData.currentThreePidData?.threePid) { return when (val threePid = pendingSessionData.currentThreePidData?.threePid) {
is RegisterThreePid.Email -> threePid.email is RegisterThreePid.Email -> threePid.email
is RegisterThreePid.Msisdn -> { is RegisterThreePid.Msisdn -> {
// Take formatted msisdn if provided by the server // Take formatted msisdn if provided by the server
pendingSessionData.currentThreePidData?.addThreePidRegistrationResponse?.formattedMsisdn?.takeIf { it.isNotBlank() } ?: threePid.msisdn pendingSessionData.currentThreePidData?.addThreePidRegistrationResponse?.formattedMsisdn?.takeIf { it.isNotBlank() } ?: threePid.msisdn
} }
null -> null
null -> null
} }
} }
...@@ -199,7 +200,8 @@ internal class DefaultRegistrationWizard( ...@@ -199,7 +200,8 @@ internal class DefaultRegistrationWizard(
override suspend fun registrationCustom( override suspend fun registrationCustom(
authParams: JsonDict, authParams: JsonDict,
initialDeviceDisplayName: String? initialDeviceDisplayName: String?,
useRefreshToken: Boolean
): RegistrationResult { ): RegistrationResult {
val safeSession = pendingSessionData.currentSession val safeSession = pendingSessionData.currentSession
?: throw IllegalStateException("developer error, call createAccount() method first") ?: throw IllegalStateException("developer error, call createAccount() method first")
...@@ -207,7 +209,7 @@ internal class DefaultRegistrationWizard( ...@@ -207,7 +209,7 @@ internal class DefaultRegistrationWizard(
val mutableParams = authParams.toMutableMap() val mutableParams = authParams.toMutableMap()
mutableParams["session"] = safeSession mutableParams["session"] = safeSession
val params = RegistrationCustomParams(auth = mutableParams, initialDeviceDisplayName = initialDeviceDisplayName) val params = RegistrationCustomParams(auth = mutableParams, initialDeviceDisplayName = initialDeviceDisplayName, refreshToken = useRefreshToken)
return performRegistrationOtherRequest(LoginType.CUSTOM, params) return performRegistrationOtherRequest(LoginType.CUSTOM, params)
} }
......
...@@ -31,5 +31,8 @@ internal data class RegistrationCustomParams( ...@@ -31,5 +31,8 @@ internal data class RegistrationCustomParams(
// device name // device name
@Json(name = "initial_device_display_name") @Json(name = "initial_device_display_name")
val initialDeviceDisplayName: String? = null val initialDeviceDisplayName: String? = null,
@Json(name = "refresh_token")
val refreshToken: Boolean = false
) )
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment