[Catalyst] Debugging Auth code

Dr. Jennifer Nussbaum bg271828 at yahoo.com
Sat Jul 5 17:25:27 BST 2008


My password field is called "password", so i left it out of the config, bec=
ause the
docs say that this is the default and therefore unnecessary.

I thought that the id_field was the name of the id; i do have an id value,
but of course the user just enters a name, not their database id.

In any case I changed the config to:

=A0__PACKAGE__->config->{'Plugin::Authentication'} =3D {=A0 =

=A0=A0=A0=A0 default_realm =3D> 'dbic',
=A0=A0=A0=A0 realms =3D> {
=A0=A0=A0 =A0dbic =3D> {
=A0=A0=A0 =A0=A0=A0=A0 credential =3D> {
=A0=A0=A0 =A0=A0=A0 =A0class =3D> 'Password',
=A0=A0=A0 =A0=A0=A0 =A0password_field =3D> 'password',
=A0=A0=A0 =A0=A0=A0 =A0password_type =3D> 'clear'
=A0=A0=A0 =A0=A0=A0=A0 },
=A0=A0=A0 =A0=A0=A0=A0 store =3D> {
=A0=A0=A0 =A0=A0=A0 =A0class =3D> 'DBIx::Class',
=A0=A0=A0 =A0=A0=A0 =A0user_class =3D> 'CiteEditorDB::User',
=A0=A0=A0 =A0=A0=A0 =A0id_field =3D> 'login'
=A0=A0=A0 =A0=A0=A0=A0 }
=A0=A0=A0 =A0}
=A0=A0=A0=A0 }
=A0};

(Sorry about the indentation, its not cut-and-pasting well.)

And i have the same result--"[debug] Unable to locate user matching user in=
fo provided"
in my log.

Anything else i can try? Thank you!

Jen

--- On Sat, 7/5/08, J. Shirley <jshirley at gmail.com> wrote:
From: J. Shirley <jshirley at gmail.com>
Subject: Re: [Catalyst] Debugging Auth code
To: bg271828 at yahoo.com, "The elegant MVC web framework" <catalyst at lists.scs=
ys.co.uk>
Date: Saturday, July 5, 2008, 9:05 AM

On Sat, Jul 5, 2008 at 7:01 AM, Dr. Jennifer Nussbaum
<bg271828 at yahoo.com> wrote:
> Hi,
>
> Im trying to convert a legacy program over to Catalyst, and in the process
> have
> tried to use the new Auth framework that i havent used before. Im having
> some
> problems that i cant debug, though, even though it looks like im doing
> things right.
>
> I got my setup from the docs and Tutorial. In my base class i use
> Authentication,
> Session Session::Store::DBIC, and Session::State::Cookie. My config is:
>
>  __PACKAGE__->config->{'Plugin::Authentication'} =3D {
>      default_realm =3D> 'dbic',
>      realms =3D> {
>      dbic =3D> {
>          credential =3D> {
>          class =3D> 'Password',
>          password_type =3D> 'clear'
>          },
>          store =3D> {
>          class =3D> 'DBIx::Class',
>          user_class =3D> 'MyDB::User'
>          }
>      }
>      }
>  };
>
> (By the way i dont really know what 'realms' does, as im not using
them now,
> but
> i thought that i can just use anything as long as im not using it
directly.)
>
> Then my login routine includes:
>
>  my $username =3D $c->request->params->{username} || "";
>   my $password =3D $c->request->params->{password} || "";
>
>   # If the username and password values were found in form
>   if ($username && $password) {
>       $c->log->debug("we have a username and pw");
>       $c->log->debug("username is >$username<, password
is >$password<");
>     # Attempt to log the user in
>     if ($c->authenticate({ login =3D> $username,
>                password =3D> $password })) {
> # ...
>
> (The name of my "username" field in the underlying table is
"login" for
> legacy
> reasons. But i thought thta using "login =3D> $username" would
address this;
> login is the right column in the table itself.)
>
> When i run DBIC_TRACE, the SQL that's executed _does_ return the user
object
> associated with this username and password combo. However, when i run
this,
> my log shows:
>
> [debug] Path is "login"
> [debug] we have a username and pw
> [debug] username is >testuser<, password is >passw0rd<
> [debug] Unable to locate user matching user info provided
>
> Since the SQL is returning the right thing, and everything else looks OK,
i
> cant
> tell why this is failing. Can someone give me some advice on debugging
this?
>
> Thanks!
>
>

Hi Jennifer,

Looks like you are missing the "password_field" config parameter:
http://search.cpan.org/~jayk/Catalyst-Plugin-Authentication-0.10006/lib/Cat=
alyst/Authentication/Credential/Password.pm#CONFIGURATION

Also, you need to have the "id_field" set in your store
configuration:
http://search.cpan.org/~jayk/Catalyst-Authentication-Store-DBIx-Class-0.104=
/lib/Catalyst/Authentication/Store/DBIx/Class.pm#CONFIGURATION

That would be the name of your username field in your MyDB::User class.




      =

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/catalyst/attachments/20080705/f8bf2=
0bc/attachment.htm


More information about the Catalyst mailing list