Skip to content

Commit

Permalink
fix error handling for CSRF-Token is invalid
Browse files Browse the repository at this point in the history
  • Loading branch information
hubermat committed Oct 14, 2022
1 parent 25aeb95 commit 5b492d6
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion ctldap.js
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,10 @@ function apiPost(site, func, data, triedLogin, triedCSRFUpdate) {
}
return result.data;
}, function (error) {
if ((error.error && error.error.errors && error.error.errors[0] && error.error.errors[0].message === "CSRF-Token is invalid") && !triedCSRFUpdate) {
if (error.error && (
(error.error.message === "CSRF-Token is invalid") ||
(error.error.errors && error.error.errors[0] && error.error.errors[0].message === "CSRF-Token is invalid")
) && !triedCSRFUpdate) {
logDebug(site, "CSRF token is invalid, get new one and retry...");
return getCsrfToken(site).then(function() {
// Retry operation
Expand Down

0 comments on commit 5b492d6

Please sign in to comment.