Skip to content

Commit

Permalink
Bumped version number to 0.03. Updated phpbb_login() to work with php…
Browse files Browse the repository at this point in the history
…bb 3.0.*.

Previous implementation of phpbb_login() didn't work with phpbb 3.0.*.
* Login/logout actions are now handled by ucp.php?mode=login/logout not login.php and logout.php.
* It seems that at the time 0.02 was written, the login page contained only the login form.
  Now on every phpbb page there is an additional search form located in the upper right corner of the page
  submit_form tried to login using that search form instead of the login form. Adding form_id to
  submit_form fixed this issue.

There is an overall problem with phpBB.pm library. Most actions fail silently and without debug
information from log4perl it's not easy to see if the user logged in successfully or that any
plugin function call was executed correctly. I may be wrong with this judgment but just noting
my current concerns.
  • Loading branch information
mulander committed Dec 27, 2009
1 parent f487dc5 commit 8a595b9
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions lib/WWW/Mechanize/Plugin/phpBB.pm
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ use 5.006;
use strict;
use warnings;

our $VERSION = '0.02';

our $VERSION = '0.03';
use Log::Log4perl qw(:easy);
use HTML::TreeBuilder;

Expand Down Expand Up @@ -49,7 +48,8 @@ sub login {

eval {
DEBUG "Finding 'Login' link ";
my $link = $mech->find_link(url_regex => qr/login\.php/);
# extended regex to recognize ucp.php?mode style urls
my $link = $mech->find_link(url_regex => qr/(login\.php|ucp\.php\?mode=login)/);
die "Cannot find login.php link" unless defined $link;

my $url = $link->url();
Expand All @@ -58,16 +58,20 @@ sub login {
$mech->follow_link(url => $url);

DEBUG "Submitting login credentials for user '$user'";
# Selecting the form by form_id without it phpBB.pm selected the search form
# located in the upper right corner of the screen.
$mech->submit_form(
form_id => 'login',
fields => {
username => $user,
password => $password,
},
button => "login",
);

# extended regex to recognize ucp.php?mode style urls
$link = $mech->find_link(
url_regex => qr/\Qlogin.php?logout=true\E/);
url_regex => qr/(login\.php\?logout=true|ucp\.php\?mode=logout)/);
die "Login failed (wrong credentials?)" unless defined $link;
};

Expand Down

0 comments on commit 8a595b9

Please sign in to comment.