[API/Usos] Fix re-logging in after user action.

This commit is contained in:
Kuba Szczodrzyński 2022-10-17 16:06:13 +02:00
parent dc19043f73
commit 3ab9602865
No known key found for this signature in database
GPG Key ID: 70CB8A85BA1633CB

View File

@ -10,10 +10,7 @@ import pl.szczodrzynski.edziennik.data.api.edziennik.usos.DataUsos
import pl.szczodrzynski.edziennik.data.api.edziennik.usos.data.UsosApi import pl.szczodrzynski.edziennik.data.api.edziennik.usos.data.UsosApi
import pl.szczodrzynski.edziennik.data.api.events.UserActionRequiredEvent import pl.szczodrzynski.edziennik.data.api.events.UserActionRequiredEvent
import pl.szczodrzynski.edziennik.data.api.models.ApiError import pl.szczodrzynski.edziennik.data.api.models.ApiError
import pl.szczodrzynski.edziennik.ext.Bundle import pl.szczodrzynski.edziennik.ext.*
import pl.szczodrzynski.edziennik.ext.fromQueryString
import pl.szczodrzynski.edziennik.ext.toBundle
import pl.szczodrzynski.edziennik.ext.toQueryString
import pl.szczodrzynski.edziennik.utils.Utils.d import pl.szczodrzynski.edziennik.utils.Utils.d
class UsosLoginApi(val data: DataUsos, val onSuccess: () -> Unit) { class UsosLoginApi(val data: DataUsos, val onSuccess: () -> Unit) {
@ -25,6 +22,9 @@ class UsosLoginApi(val data: DataUsos, val onSuccess: () -> Unit) {
init { init {
run { run {
data.arguments?.getString("oauthLoginResponse")?.let {
data.oauthLoginResponse = it
}
if (data.isApiLoginValid()) { if (data.isApiLoginValid()) {
onSuccess() onSuccess()
} else if (data.oauthLoginResponse != null) { } else if (data.oauthLoginResponse != null) {
@ -36,6 +36,8 @@ class UsosLoginApi(val data: DataUsos, val onSuccess: () -> Unit) {
} }
private fun authorize() { private fun authorize() {
data.oauthTokenKey = null
data.oauthTokenSecret = null
api.apiRequest<String>( api.apiRequest<String>(
tag = TAG, tag = TAG,
service = "oauth/request_token", service = "oauth/request_token",