]> projects.mako.cc - mw/blobdiff - src/mw/clicommands.py
Add CSRF support (MediaWiki bug 23076)
[mw] / src / mw / clicommands.py
index de08cb64a32097780697c3567d7b1974a44547d0..a42bcfbab0107492d5f2c0b6acfac9d910228dc1 100644 (file)
@@ -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']
 

Benjamin Mako Hill || Want to submit a patch?