Authen-Simple-WebForm
view release on metacpan or search on metacpan
lib/Authen/Simple/WebForm.pm view on Meta::CPAN
# get an inital page?
if ($self->initial_url)
{
my $res = ($initial_req_method eq 'GET') ? $ua->get($self->initial_url, @headers):
$ua->post($self->initial_url, @headers);
if ($self->trace)
{
print STDERR ("-"x80)."\n";
print STDERR "TRACE: initial response, response code [".$res->code."]\n";
print STDERR "TRACE: initial response, cookies [".$ua->cookie_jar->as_string()."]\n";
print STDERR $res->decoded_content;
print STDERR "\n\n\n";
print STDERR ("-"x80)."\n";
}
# make sure status code is ok?
if ($self->check_initial_status_code)
{
unless ($res->is_success)
{
$self->log->error("Can't get ".$self->initial_url." -- ".$res->status_line)
if $self->log;
lib/Authen/Simple/WebForm.pm view on Meta::CPAN
}
}
# do we care to check the content?
if ($self->initial_expect)
{
my $expect = $self->initial_expect;
unless (ref($expect) eq 'Regexp') {
$expect = qr/\Q$expect\E/;
}
unless ($res->decoded_content =~ /$expect/)
{
$self->log->error("Initial url didn't return expected results.") if $self->log;
return 0;
}
}
# do we care to check for a cookie
if ($self->initial_expect_cookie)
{
my $expect = $self->initial_expect_cookie;
lib/Authen/Simple/WebForm.pm view on Meta::CPAN
$url->query_form( \@data );
$res = $ua->get($url, @headers);
} else { # POST
$res = $ua->post($self->login_url, \@data, @headers);
}
if ($self->trace)
{
print STDERR ("-"x80)."\n";
print STDERR "TRACE: initial response, response code [".$res->code."]\n";
print STDERR "TRACE: initial response, cookies [".$ua->cookie_jar->as_string()."]\n";
print STDERR $res->decoded_content;
print STDERR "\n\n\n";
print STDERR ("-"x80)."\n";
}
# make sure status code is ok?
if ($self->check_login_status_code)
{
unless ($res->is_success)
{
if ($res->is_redirect)
lib/Authen/Simple/WebForm.pm view on Meta::CPAN
}
}
# do we care to check the content?
if ($self->login_expect)
{
my $expect = $self->login_expect;
unless (ref($expect) eq 'Regexp') {
$expect = qr/\Q$expect\E/;
}
unless ($res->decoded_content =~ /$expect/)
{
$self->log->debug("Failed to authenticate user '$full_username'. Reason: Login page response did not match expected value.")
if $self->log;
return 0;
}
}
# do we care to check for a cookie
if ($self->login_expect_cookie)
{
( run in 0.236 second using v1.01-cache-2.11-cpan-26ccb49234f )