[Catalyst] problem with Authentication::CDBI

michael reece mreece at sacbee.com
Wed Jun 1 21:36:32 CEST 2005


i ran into this, too.  putting your 'sub login' in your app causes it  
to conflict with the login sub that is imported from the Auth::CDBI  
plugin.

put it in MyApp::C::Login as sub login : Global, and then $c->forward 
('/login/login')

(or call it signin instead of login, if it must live in MyApp.  but  
you'll run into this with any sub name that conflicts with any sub  
name on any plugin, so get used to separate controllers)


On Jun 1, 2005, at 12:19 PM, Srinivasa Mullangi wrote:

> Hi,
>
> I am trying to implement 'Authentication with  
> Catalyst::Plugin::Authentication::CDBI'  example from the cook book.
>
> Here is my config and code
>         authentication => {     user_class => 'User',
>                                 user_field => 'email',
>                                 password_field => 'password',
>                                 role_class      => 'Roles',
>                               &! nbsp; user_role_class => 'UserRoles',
>                                 user_role_user_field => 'user_id',
>                                 user_role_role_field => 'role_id',
>                         },
> sub begin : Private {
>         my ( $self, $c ) = @_;
>         unless ($c->req->{user}) {
>                 $c->req->action(undef);
>                 $c->forward('/login');
>         }
> }
> my $loginprofile = {
>         required => [qw(username password)],
> };
>
> sub login : Local {
>         my ($self, $c) = @_;
>         $c->stash->{template} = 'template/login.tt';
>         if($c->req->params->{submit}) {
>                 my $results = Data::FormValidator->check($c->req- 
> >params, $loginprofile);
>                 if($results->has_missing() || $results->has_invalid 
> ()) {
>                         $c->stash->{error} = 'Error in the  
> submitted data';
>                         $c->stash->{results} = $results;
>                         return;
>                 }
>                 $c->session_login($c->req->params->{username}, $c- 
> >req->params->{password});
>                 if ($c->req->{user}) {
>                         $c->forward('/');
>                 }
>         }
> }
>
> I created an user with email: 'mullangi at rocketmail.com' and  
> password 'abcde'.
> I am getting the following error from the method $c->session_login 
> (...)
>
> [Wed Jun  1 10:45:27 2005] [catalyst] [error] Caught exception  
> "Can't locate object method "log" via package  
> "mullangi at rocketmail.com" (perhaps you forgot to load  
> "mullangi at rocketmail.com"?) at /var/www/BettyMills-Admin/script/../ 
> lib/BettyMills/Admin.pm line 54."
> Please advise on what is going wrong and how to fix.
>
> Thanks
> Srini
>
> __________________________________________________
> Do You Yahoo!?
> Tired of spam? Yahoo! Mail has the best spam protection around
> http://mail.yahoo.com
>
> _______________________________________________
> Catalyst mailing list
> Catalyst at lists.rawmode.org
> http://lists.rawmode.org/mailman/listinfo/catalyst
>




More information about the Catalyst mailing list