From e9de08c3aab4d4163a2263c62a691b6a396ffeb4 Mon Sep 17 00:00:00 2001
From: OverlordQ <overlordq@gmail.com>
Date: Wed, 7 Apr 2010 01:57:05 +0000
Subject: [PATCH] Patch for new login system
---
lib/MediaWiki/API.pm | 22 ++++++++++++++++------
1 files changed, 16 insertions(+), 6 deletions(-)
diff --git a/lib/MediaWiki/API.pm b/lib/MediaWiki/API.pm
index 88bb182..3f66bfe 100644
--- a/lib/MediaWiki/API.pm
+++ b/lib/MediaWiki/API.pm
@@ -40,11 +40,11 @@ MediaWiki::API - Provides a Perl interface to the MediaWiki API (
http://www.medi
=head1 VERSION
-Version 0.29
+Version 0.30
=cut
-our $VERSION = "0.29";
+our $VERSION = "0.30";
=head1 SYNOPSIS
@@ -219,11 +219,21 @@ sub login {
# reassign hash reference to the login section
my $login = $ref->{login};
- return $self->_error( ERR_LOGIN, 'Login Failure - ' . $login->{result} )
- unless ( $login->{result} eq 'Success' );
- # everything was ok so return the reference
- return $login;
+ # Do login token checking
+ if( $login->{result} eq 'Success' ) {
+ return $login;
+ } elsif ( $login->{result} eq 'NeedToken' ) {
+ my $token = $login->{token};
+ $query->{lgtoken} = $token;
+ #Resubmit previous request with token
+ return undef unless ( $ref = $self->api( $query ) );
+ $login = $ref->{login};
+
+ return $login if ( $login->{result} eq 'Success' );
+ }
+
+ return $self->_error( ERR_LOGIN, 'Login Failure - ' . $login->{result} )
}
=head2 MediaWiki::API->api( $query_hashref, $options_hashref )
--
1.7.0.4