mirror of
https://github.com/szkolny-eu/szkolny-android.git
synced 2024-11-24 10:54:36 -06:00
[API/Mobidziennik] Do not clear email field if not set.
This commit is contained in:
parent
a9a0630226
commit
6d3eb65445
@ -10,6 +10,7 @@ import pl.szczodrzynski.edziennik.data.api.edziennik.mobidziennik.ENDPOINT_MOBID
|
||||
import pl.szczodrzynski.edziennik.data.api.edziennik.mobidziennik.data.MobidziennikWeb
|
||||
import pl.szczodrzynski.edziennik.ext.DAY
|
||||
import pl.szczodrzynski.edziennik.ext.get
|
||||
import pl.szczodrzynski.edziennik.ext.isNotNullNorBlank
|
||||
|
||||
class MobidziennikWebAccountEmail(override val data: DataMobidziennik,
|
||||
override val lastSync: Long?,
|
||||
@ -24,6 +25,7 @@ class MobidziennikWebAccountEmail(override val data: DataMobidziennik,
|
||||
MobidziennikLuckyNumberExtractor(data, text)
|
||||
|
||||
val email = Regexes.MOBIDZIENNIK_ACCOUNT_EMAIL.find(text)?.let { it[1] }
|
||||
if (email.isNotNullNorBlank())
|
||||
data.loginEmail = email
|
||||
|
||||
data.setSyncNext(ENDPOINT_MOBIDZIENNIK_WEB_ACCOUNT_EMAIL, if (email == null) 3* DAY else 7* DAY)
|
||||
|
@ -16,6 +16,7 @@ import pl.szczodrzynski.edziennik.data.api.models.ApiError
|
||||
import pl.szczodrzynski.edziennik.ext.JsonObject
|
||||
import pl.szczodrzynski.edziennik.ext.getJsonObject
|
||||
import pl.szczodrzynski.edziennik.ext.getString
|
||||
import pl.szczodrzynski.edziennik.ext.isNotNullNorBlank
|
||||
import pl.szczodrzynski.edziennik.ext.isNotNullNorEmpty
|
||||
import pl.szczodrzynski.edziennik.utils.Utils
|
||||
|
||||
@ -77,7 +78,9 @@ class MobidziennikLoginApi2(val data: DataMobidziennik, val onSuccess: () -> Uni
|
||||
}
|
||||
}
|
||||
|
||||
data.loginEmail = json.getString("email")
|
||||
val email = json.getString("email")
|
||||
if (email.isNotNullNorBlank())
|
||||
data.loginEmail = email
|
||||
data.globalId = json.getString("id_global")
|
||||
data.loginId = json.getString("login")
|
||||
onSuccess()
|
||||
|
@ -6,6 +6,8 @@ package pl.szczodrzynski.edziennik.data.db.enums
|
||||
|
||||
import pl.szczodrzynski.edziennik.data.db.entity.LoginStore
|
||||
import pl.szczodrzynski.edziennik.data.db.entity.Profile
|
||||
import pl.szczodrzynski.edziennik.ext.getString
|
||||
import pl.szczodrzynski.edziennik.ext.isNotNullNorBlank
|
||||
|
||||
enum class LoginMethod(
|
||||
val loginType: LoginType,
|
||||
@ -26,7 +28,7 @@ enum class LoginMethod(
|
||||
MOBIDZIENNIK_API2(
|
||||
loginType = LoginType.MOBIDZIENNIK,
|
||||
id = 1300,
|
||||
isPossible = { profile, _ -> profile?.studentData?.has("email") ?: false },
|
||||
isPossible = { profile, _ -> profile?.studentData?.getString("email").isNotNullNorBlank() },
|
||||
),
|
||||
LIBRUS_PORTAL(
|
||||
loginType = LoginType.LIBRUS,
|
||||
@ -57,7 +59,7 @@ enum class LoginMethod(
|
||||
VULCAN_WEB_MAIN(
|
||||
loginType = LoginType.VULCAN,
|
||||
id = 4100,
|
||||
isPossible = { _, loginStore -> loginStore.hasLoginData("webHost") },
|
||||
isPossible = { _, loginStore -> loginStore.getLoginData("webHost", null).isNotNullNorBlank() },
|
||||
),
|
||||
VULCAN_HEBE(
|
||||
loginType = LoginType.VULCAN,
|
||||
|
Loading…
Reference in New Issue
Block a user