[AGRUNDMA - Thu Dec 15 17:37:50 2005]:
Show quoted text> Sounds like you're doing something like if ( $c->user->username ). What
> you really want to do is this:
>
> if ( $c->login( $username, $password ) ) {
> # user is logged in, now you can use $c->user
> }
>
> or...
>
> $c->login( $username, $password );
> if ( $c->user_exists ) {
> # user is logged in, now you can use $c->user
> }
Sorry - should have provided more context. I am experimenting based on
the advent calendar examples at
http://catalyst.perl.org/calendar/2005/14
The Authentication Authentication::Credential::Password
Authentication::Store::Htpasswd Authorization::Roles plugins are loaded.
The only function touching authentication at present is in the main app
module (ie rather than a controller module):-
sub dologin : Local {
my ($self, $c) = @_;
$c->stash->{template} = 'login.tt2';
my $user = $c->req->param("user");
my $password = $c->req->param("password");
if ($user && $password) {
if ( $c->login($user, $password) ) {
$c->stash->{message} = 'Login OK';
} else {
# login incorrect
$c->stash->{message} = 'Login incorrect';
}
} else {
$c->stash->{message} = 'No credentials';
}
}
The name had to be changed from 'login' since otherwise the $c->login
loops back to here (with amusing consequences).
This, on its own, causes an exception if an unknown username is entered.
Thats why I considered it a bug in the auth module.
[Originally mailed, then added to the web f/e when if failed to appear]