[html-formfu] applying a filter

Octavian Rasnita orasnita at gmail.com
Sun Jan 11 09:21:38 GMT 2009


Hello,

I am trying to find the best way of storing an encrypted password in the 
database (when creating a new user for example).

I thought that using a filter might be the best way for this and using a 
callback would be enough:

<filters>
  type Callback
  callback Digest::SHA1::sha1_hex
</filters>

The single problem is that it doesn't work.

Digest::SHA1::sha1_hex returns the encrypted string, so it should work, but 
I don't know why, it doesn't.

I have also tried to use a 'use Digest::SHA1;' in MyApp.pm, even though 
without it it didn't give any error, however it still doesn't work, and the 
unencrypted string is inserted in the database.

The code I use for inserting the user is:

if ($form->submitted_and_valid) {
my $user = $form->param_value('user');
my $email = $form->param_value('email');
my $hash = sha1_hex($user . $email . time());

my $new_user = $c->model("DB::TempUser")->new_result({hash => $hash});
$form->process;
$form->model->update($new_user);
}

Am I doing something wrong, or the filter can't be used for what I want?

Thanks.

Octavian




More information about the HTML-FormFu mailing list