[Catalyst] Auth tutorial merry-go-round

Ash Berlin ash_cpan at firemirror.com
Mon Jul 7 10:14:37 BST 2008


On 7 Jul 2008, at 09:40, Dermot wrote:

> Hi,
>
> I have been following the tutorial and am stuck in a loop. In my Root
> controller I have the following
>
> sub auto : Private {
>   my ($self,$c) = @_;
>   if ($c->controller eq $c->controller('Login')) {
>        return 1;
>   }
>   if (!$c->user_exists) {
>        $c->log->debug('***Root::auto User not found, forwarding to / 
> login');
>        $c->response->redirect($c->uri_for('/login'));
>        return 0;
>   }
> # user found
>   return 1;
> }
>
> In my Login controller I have
>
> sub index :Path :Args(0) {
>    my ( $self, $c ) = @_;
>
> # Get the username and password from form
>    my $username = $c->request->params->{username} || "";
>    my $password = $c->request->params->{password} || "";
>
> # If the username and password values were found in form
>    if ($username && $password) {
>        # Attempt to log the user in
>        $c->log->debug("User=$username, Password=$password");
>        if ($c->authenticate({ username => $username,password =>
> $password} ) ) {
> # If successful, then let them use the application
>                $c->log->debug("Login Success");
>                $c->response->redirect($c->uri_for('/books/list'));
>                return;
>         } else {
> # Set an error message
>                $c->stash->{error_msg} = "Bad username or password.";
>         }
>     }
> # If either of above don't work out, send to the login page
>    $c->stash->{template} = 'login.tt2';
> }
>
>
> When i login I see these debug messages
>
> [debug] Path is "login"
> [debug] User=admin, Password=admin
> [debug] Created session "0628e51d5825d7309fd64a2404dd907bbea0ae27"
> [debug] Login Success
> ...
> .---------------------------------------------------------------- 
> +-----------.
> | Action                                                         |  
> Time      |
> +---------------------------------------------------------------- 
> +-----------+
> | /auto                                                          |  
> 0.000649s |
> | /login/index                                                   |  
> 0.032623s |
> | /end
> ...
> [debug] "GET" request for "books/list" from "127.0.0.1"
> [debug] Path is "books/list"
> [debug] ***Root::auto User not found, forwarding to /login
> [debug] Redirecting to "http://localhost:3000/login"
>
> So while $c->authenticate can see my login in my Login controller, it
> can't in Root/auto !!!  Can anyone point tell where I am going wrong?
> TIA,
> Dp.
>
>

What session store and state modules are you using? I know this  
happens to me when I forget to load up memcached (which is the store  
module i'm using)

-ash




More information about the Catalyst mailing list