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 {
|
class ErrorInterceptor : Interceptor {
|
||||||
|
|
||||||
companion object {
|
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 {
|
override fun intercept(chain: Interceptor.Chain): Response {
|
||||||
|
@ -44,6 +45,13 @@ class ErrorInterceptor : Interceptor {
|
||||||
if (it.isNotEmpty()) throw AccountPermissionException(it.text())
|
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()) {
|
when (doc.title()) {
|
||||||
"Błąd" -> throw VulcanException(doc.body().text())
|
"Błąd" -> throw VulcanException(doc.body().text())
|
||||||
"Błąd strony" -> throw VulcanException(doc.select(".errorMessage").text())
|
"Błąd strony" -> throw VulcanException(doc.select(".errorMessage").text())
|
||||||
|
@ -51,7 +59,6 @@ class ErrorInterceptor : Interceptor {
|
||||||
"Przerwa techniczna" -> throw ServiceUnavailableException(doc.title())
|
"Przerwa techniczna" -> throw ServiceUnavailableException(doc.title())
|
||||||
"Strona nie została odnaleziona" -> throw ScrapperException(doc.title())
|
"Strona nie została odnaleziona" -> throw ScrapperException(doc.title())
|
||||||
"Strona nie znaleziona" -> throw ScrapperException(doc.selectFirst("div div").text())
|
"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 {
|
doc.select("h2").text().let {
|
||||||
|
|
Loading…
Reference in a new issue