From e31cbf92b32521b46527e9b2a2bfecca408d05d1 Mon Sep 17 00:00:00 2001 From: Yves Tennevin Date: Sun, 25 Apr 2010 04:52:47 -0500 Subject: [PATCH] Add CSRF support (MediaWiki bug 23076) https://bugzilla.wikimedia.org/show_bug.cgi?id=23076 --- src/mw/clicommands.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/mw/clicommands.py b/src/mw/clicommands.py index de08cb6..a42bcfb 100644 --- a/src/mw/clicommands.py +++ b/src/mw/clicommands.py @@ -57,6 +57,16 @@ class CommandBase(object): if result['login']['result'] == 'Success': # cookies are saved to a file print 'Login successful! (yay)' + elif result['login']['result'] == 'NeedToken': + print'Login with token' + result = self.api.call({'action': 'login', + 'lgname': user, + 'lgpassword': passwd, + 'lgtoken': result['login']['token']}) + if result['login']['result'] == 'Success': + print 'Login successful! (yay)' + else: + print 'Login failed: %s' % result['login']['result'] else: print 'Login failed: %s' % result['login']['result'] -- 2.39.5