Send session rebuild in separate request
This commit is contained in:
parent
c26b6cabd3
commit
59c15235e0
3 changed files with 8 additions and 4 deletions
|
@ -40,7 +40,10 @@ class LoginHelper(
|
|||
it.action.isBlank() -> throw VulcanException("Invalid certificate page: '${it.title}'. Try again")
|
||||
}
|
||||
|
||||
sendCertificate(it, email.substringAfter("||", ""))
|
||||
sendCertificate(it)
|
||||
}.flatMap {
|
||||
if (email.contains("||")) switchLogin(email.substringAfter("||", ""), symbol)
|
||||
else Single.just(it)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -59,9 +62,9 @@ class LoginHelper(
|
|||
}
|
||||
}
|
||||
|
||||
fun sendCertificate(certificate: CertificateResponse, email: String = "", url: String = certificate.action): Single<SendCertificateResponse> {
|
||||
fun sendCertificate(certificate: CertificateResponse, url: String = certificate.action): Single<SendCertificateResponse> {
|
||||
cookies.cookieStore.removeAll()
|
||||
return api.sendCertificate(url + if (email.isNotBlank()) "?rebuild=$email" else "", mapOf(
|
||||
return api.sendCertificate(url, mapOf(
|
||||
"wa" to certificate.wa,
|
||||
"wresult" to certificate.wresult,
|
||||
"wctx" to certificate.wctx
|
||||
|
|
|
@ -34,7 +34,7 @@ class RegisterRepository(
|
|||
|
||||
fun getStudents(): Single<List<Student>> {
|
||||
return getSymbols().flatMapObservable { Observable.fromIterable(it) }.flatMap { (symbol, certificate) ->
|
||||
loginHelper.sendCertificate(certificate, "", certificate.action.replace(startSymbol.getNormalizedSymbol(), symbol))
|
||||
loginHelper.sendCertificate(certificate, certificate.action.replace(startSymbol.getNormalizedSymbol(), symbol))
|
||||
.onErrorResumeNext { t ->
|
||||
if (t is AccountPermissionException) Single.just(SendCertificateResponse())
|
||||
else Single.error(t)
|
||||
|
|
|
@ -69,6 +69,7 @@ class LoginTest : BaseLocalTest() {
|
|||
fun multiLogin_withLogin() {
|
||||
server.enqueue(MockResponse().setBody(LoginTest::class.java.getResource("Logowanie-uonet.html").readText()))
|
||||
server.enqueue(MockResponse().setBody(LoginTest::class.java.getResource("Login-success-account-switch.html").readText()))
|
||||
server.enqueue(MockResponse().setBody(LoginTest::class.java.getResource("Login-success-account-switch.html").readText()))
|
||||
server.start(3000)
|
||||
|
||||
val res = normal.login("jan||jan@fakelog.cf", "jan123").blockingGet()
|
||||
|
|
Loading…
Reference in a new issue