Change password reset detection in ErrorInterceptor
This commit is contained in:
parent
08dec15f65
commit
99b026435f
1 changed files with 9 additions and 2 deletions
|
@ -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 {
|
||||
|
|
Loading…
Reference in a new issue