forked from github/szkolny
[Vulcan/Web] Fix checking login expiry time.
This commit is contained in:
parent
9da6dbccb3
commit
b75ab76c2a
@ -17,7 +17,7 @@ import pl.szczodrzynski.edziennik.utils.Utils
|
|||||||
|
|
||||||
class DataVulcan(app: App, profile: Profile?, loginStore: LoginStore) : Data(app, profile, loginStore) {
|
class DataVulcan(app: App, profile: Profile?, loginStore: LoginStore) : Data(app, profile, loginStore) {
|
||||||
fun isWebMainLoginValid() = symbol.isNotNullNorEmpty()
|
fun isWebMainLoginValid() = symbol.isNotNullNorEmpty()
|
||||||
&& (webExpiryTime[symbol] ?: 0) - 30 > currentTimeUnix()
|
&& (webExpiryTime[symbol]?.toLongOrNull() ?: 0) - 30 > currentTimeUnix()
|
||||||
&& webAuthCookie[symbol].isNotNullNorEmpty()
|
&& webAuthCookie[symbol].isNotNullNorEmpty()
|
||||||
&& webHost.isNotNullNorEmpty()
|
&& webHost.isNotNullNorEmpty()
|
||||||
&& webType.isNotNullNorEmpty()
|
&& webType.isNotNullNorEmpty()
|
||||||
@ -358,10 +358,10 @@ class DataVulcan(app: App, profile: Profile?, loginStore: LoginStore) : Data(app
|
|||||||
* If the time passes, the certificate needs to be POSTed again (if valid)
|
* If the time passes, the certificate needs to be POSTed again (if valid)
|
||||||
* or re-generated.
|
* or re-generated.
|
||||||
*/
|
*/
|
||||||
var webExpiryTime: Map<String, Long?> = mapOf()
|
var webExpiryTime: Map<String, String?> = mapOf()
|
||||||
get() { mWebExpiryTime = mWebExpiryTime ?: loginStore.getLoginData("webExpiryTime", null)?.let { app.gson.fromJson(it, field.toMutableMap()::class.java) }; return mWebExpiryTime ?: mapOf() }
|
get() { mWebExpiryTime = mWebExpiryTime ?: loginStore.getLoginData("webExpiryTime", null)?.let { app.gson.fromJson(it, field.toMutableMap()::class.java) }; return mWebExpiryTime ?: mapOf() }
|
||||||
set(value) { loginStore.putLoginData("webExpiryTime", app.gson.toJson(value)); mWebExpiryTime = value }
|
set(value) { loginStore.putLoginData("webExpiryTime", app.gson.toJson(value)); mWebExpiryTime = value }
|
||||||
private var mWebExpiryTime: Map<String, Long?>? = null
|
private var mWebExpiryTime: Map<String, String?>? = null
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* EfebSsoAuthCookie retrieved after posting a certificate
|
* EfebSsoAuthCookie retrieved after posting a certificate
|
||||||
|
@ -86,7 +86,7 @@ open class VulcanWebMain(open val data: DataVulcan, open val lastSync: Long?) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
data.webExpiryTime = data.webExpiryTime.toMutableMap().also { map ->
|
data.webExpiryTime = data.webExpiryTime.toMutableMap().also { map ->
|
||||||
map[symbol] = Date.fromIso(certificate.expiryDate) / 1000L
|
map[symbol] = (Date.fromIso(certificate.expiryDate) / 1000L).toString()
|
||||||
}
|
}
|
||||||
onResult(symbol, STATE_SUCCESS)
|
onResult(symbol, STATE_SUCCESS)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user