[Catalyst] Problem with authentication

Renee Bäcker mailinglisten at renee-baecker.de
Wed Apr 22 11:55:15 GMT 2009


Hi *,

I want to use authentication in my catalyst app. The authentication
seems to work, but I can't access any user information as $c->user is
undefined.

My code looks like this:

use Catalyst qw/
    -Debug
    Static::Simple

    ConfigLoader
    Redirect

    Session
    Session::State::Cookie
    Session::Store::DBI

    Authentication
    Authorization::Roles
/;

sub login : Local {
    my ($self,$c) = @_;

    my $params = $c->req->params;
    my ($user,$pass) = @{$params}{qw/username password/};

    my $result = $user and $pass and $c->authenticate({
        username => $user,
        password => $pass,
    });

    if( $result ){
        $c->log->debug( 'login successful: ' . $c->user );
        $c->redirect( $c->uri_for( '/start' ) );
    }
    else{
        # error message
    }
}

The log says "login successful:" but nothing more.

What is wrong with my code?

- Renée
-- 

Perl-Magazin: http://perl-magazin.de
Perl-Nachrichten: http://perl-nachrichten.de



More information about the Catalyst mailing list