Change password reset detection in ErrorInterceptor

This commit is contained in:
Mikołaj Pich 2020-02-03 14:34:18 +01:00
parent 08dec15f65
commit 99b026435f
No known key found for this signature in database
GPG key ID: F62B26E36D4C4BAA

View file

@ -14,7 +14,8 @@ import org.slf4j.LoggerFactory
class ErrorInterceptor : Interceptor {
companion object {
@JvmStatic private val logger = LoggerFactory.getLogger(this::class.java)
@JvmStatic
private val logger = LoggerFactory.getLogger(this::class.java)
}
override fun intercept(chain: Interceptor.Chain): Response {
@ -44,6 +45,13 @@ class ErrorInterceptor : Interceptor {
if (it.isNotEmpty()) throw AccountPermissionException(it.text())
}
doc.select("form")?.attr("action")?.let {
if ("SetNewPassword" in it) {
logger.debug(redirectUrl)
throw PasswordChangeRequiredException("Wymagana zmiana hasła użytkownika", redirectUrl)
}
}
when (doc.title()) {
"Błąd" -> throw VulcanException(doc.body().text())
"Błąd strony" -> throw VulcanException(doc.select(".errorMessage").text())
@ -51,7 +59,6 @@ class ErrorInterceptor : Interceptor {
"Przerwa techniczna" -> throw ServiceUnavailableException(doc.title())
"Strona nie została odnaleziona" -> throw ScrapperException(doc.title())
"Strona nie znaleziona" -> throw ScrapperException(doc.selectFirst("div div").text())
"Zmiana hasła użytkownika" -> { logger.debug(redirectUrl); throw PasswordChangeRequiredException("Wymagana zmiana hasła użytkownika", redirectUrl) }
}
doc.select("h2").text().let {