This repository was archived by the owner on Feb 4, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +17
-2
lines changed
fluxc/src/main/java/org/wordpress/android/fluxc/network/rest/wpapi Expand file tree Collapse file tree 2 files changed +17
-2
lines changed Original file line number Diff line number Diff line change @@ -19,6 +19,7 @@ sealed interface Nonce {
1919 enum class CookieNonceErrorType {
2020 NOT_AUTHENTICATED ,
2121 INVALID_RESPONSE ,
22+ INVALID_CREDENTIALS ,
2223 CUSTOM_LOGIN_URL ,
2324 CUSTOM_ADMIN_URL ,
2425 INVALID_NONCE ,
Original file line number Diff line number Diff line change @@ -69,11 +69,18 @@ class NonceRestClient @Inject constructor(
6969 // that it's an authentication issue, otherwise we'll assume it's an invalid response
7070 val errorMessage = extractErrorMessage(response.data.orEmpty())
7171
72+ val errorType = if (hasInvalidCredentialsPattern(response.data.orEmpty())) {
73+ Nonce .CookieNonceErrorType .INVALID_CREDENTIALS
74+ } else if (errorMessage != null ) {
75+ Nonce .CookieNonceErrorType .NOT_AUTHENTICATED
76+ } else {
77+ Nonce .CookieNonceErrorType .INVALID_RESPONSE
78+ }
79+
7280 FailedRequest (
7381 timeOfResponse = currentTimeProvider.currentDate().time,
7482 username = username,
75- type = if (errorMessage != null ) Nonce .CookieNonceErrorType .NOT_AUTHENTICATED
76- else Nonce .CookieNonceErrorType .INVALID_RESPONSE ,
83+ type = errorType,
7784 errorMessage = errorMessage
7885 )
7986 }
@@ -145,4 +152,11 @@ class NonceRestClient @Inject constructor(
145152 return HtmlUtils .fastStripHtml(errorHtml)
146153 .trim(' ' , ' \n ' )
147154 }
155+
156+ private fun hasInvalidCredentialsPattern (htmlResponse : String ) =
157+ htmlResponse.contains(INVALID_CREDENTIAL_HTML_PATTERN )
158+
159+ companion object {
160+ const val INVALID_CREDENTIAL_HTML_PATTERN = " document.querySelector('form').classList.add('shake')"
161+ }
148162}
You can’t perform that action at this time.
0 commit comments