You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Brian Abernathy <ba...@purdue.edu> on 2003/04/07 23:09:17 UTC

[mp2] Apache::RequestRec user method not found

I am running apache 2.0.44 and mod_perl 1.99_08 on a solaris 9/sparc platform.  The following error appears in the apache error log when using a simple PerlAuthenHandler (code below, mostly borrowed from the mod_perl2.0 documentation)...

Can't locate object method "user" via package "Apache::RequestRec".  

The get_basic_auth_pw method works fine, any ideas why user() is having issues?  

Brian

--------------------------------------------------------------------
use Apache::Access ();
use Apache::RequestUtil ();
use Apache::Const -compile => qw(OK DECLINED AUTH_REQUIRED);

sub handler {
        my $r = shift;
        my ($status, $password) = $r->get_basic_auth_pw;
        unless ($status == Apache::OK) { return $status; }
        my $user = $r->user;
        if ("$user" eq 'test' && "$password" eq 'test') { return Apache::OK; }
        else { $r->note_basic_auth_failure; return Apache::AUTH_REQUIRED; }
}

1;
--------------------------------------------------------------------

Re: [mp2] Apache::RequestRec user method not found

Posted by Brian Abernathy <ba...@purdue.edu>.
Sorry about the HTML formatting, here is a re-post in plain text. : )

I am running apache 2.0.44 and mod_perl 1.99_08 on a solaris 9/sparc platform.  The following error appears in the apache error log when using a simple PerlAuthenHandler (code below, mostly borrowed from the mod_perl2.0 documentation)...

Can't locate object method "user" via package "Apache::RequestRec".  

The get_basic_auth_pw method works fine, any ideas why user() is having issues?  

Brian

--------------------------------------------------------------------
use Apache::Access ();
use Apache::RequestUtil ();
use Apache::Const -compile => qw(OK DECLINED AUTH_REQUIRED);

sub handler {
        my $r = shift;
        my ($status, $password) = $r->get_basic_auth_pw;
        unless ($status == Apache::OK) { return $status; }
        my $user = $r->user;
        if ("$user" eq 'test' && "$password" eq 'test') { return Apache::OK; }
        else { $r->note_basic_auth_failure; return Apache::AUTH_REQUIRED; }
}

1;
--------------------------------------------------------------------