Sunday, June 17, 2007

Catalyst and DBIx-Class tip

* Catalyst Tip: use set_authenticated instead of login when password is SHA1 hashed.

well, Foorum use SHA1 to encrypt the password. so no one knows the original password including me (db do not store original password).
so if u are trying $c->login($username, $password_sha1_hashed);, it will fail.
if u are checking the module of Catalyst::Plugin::Authentication::Credential::Password which sub login is there, we would know the solution:
$c->set_authenticated($user);

that does the same as login but no password check.

* DBIx::Class Tip: attribute offset.

sometimes when we run a SQL, that's not something like LIMIT 0,6 LIMIT 6,6
it might be something like LIMIT 5,6
well, the attributes of "rows" and "page" does something like LIMIT 6,6. but no luck with 5,6.
so if u want run a SQL with LIMIT 5,6, u might can try
search( {}, {
rows => 6,
offset => 5
} );
that would be what u want.

be careful, offset do no create a Data::Page object for you. I mean ->pager. u need create that yourself.

Enjoy!

Labels: ,

0 Comments:

Post a Comment

Links to this post:

Create a Link

<< Home