jenkins-bot merged this change.

View Change

Approvals: Xqt: Looks good to me, approved jenkins-bot: Verified
[bugfix] Fix handling of badtoken response for login actions

Fail early (before handling 'badtoken' which needs to be logged in)
if 'badtoken' error code and login in process.

Bug: T248768
Bug: T248767
Bug: T224712
Change-Id: I2c61eba72559cc27d88506bafeb46fe814f80f6f
---
M pywikibot/data/api.py
1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/pywikibot/data/api.py b/pywikibot/data/api.py
index 3e201fb..57a76ee 100644
--- a/pywikibot/data/api.py
+++ b/pywikibot/data/api.py
@@ -1834,7 +1834,12 @@
elif code == 'assertuserfailed':
message = 'User assertion failed.'

- # Lastly, the purge module require a POST if used as anonymous user,
+ # If incorrect login token was used, we are logged out too.
+ elif (self.site._loginstatus == pywikibot.site.LoginStatus.IN_PROGRESS
+ and code == 'badtoken'):
+ message = 'Received incorrect login token.'
+
+ # Lastly, the purge module requires a POST if used as anonymous user,
# but we normally send a GET request. If the API tells us the request
# has to be POSTed, we're probably logged out.
elif code == 'mustbeposted' and self.action == 'purge':

To view, visit change 584195. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I2c61eba72559cc27d88506bafeb46fe814f80f6f
Gerrit-Change-Number: 584195
Gerrit-PatchSet: 5
Gerrit-Owner: Dvorapa <dvorapa@seznam.cz>
Gerrit-Reviewer: Xqt <info@gno.de>
Gerrit-Reviewer: jenkins-bot (75)