]> projects.mako.cc - mw/commitdiff
Add CSRF support (MediaWiki bug 23076)
authorYves Tennevin <esby@free.fr>
Sun, 25 Apr 2010 09:52:47 +0000 (04:52 -0500)
committerIan Weller <ian@ianweller.org>
Sun, 25 Apr 2010 09:52:47 +0000 (04:52 -0500)
https://bugzilla.wikimedia.org/show_bug.cgi?id=23076

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)'
         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']
 
         else:
             print 'Login failed: %s' % result['login']['result']
 

Benjamin Mako Hill || Want to submit a patch?