[html-formfu] applying a filter
Moritz Onken
onken at houseofdesign.de
Tue May 12 15:39:51 GMT 2009
Am 30.04.2009 um 17:09 schrieb Ascii King:
> I am unable to figure out what was decided here. I am trying to set
> up a simple page to accept a new user with an encrypted password.
> would someone be able to show me what I need to add to my config
> file, subroutine and my .yml file to make this work?
>
> I only ask because it seems the answer put forward by David Schmidt
> where he wrote his own filter, was rejected.
This should be handled in your model.
my MyApp::Schema::User has the following methods:
sub crypt_password {
shift;
my $csh = Crypt::SaltedHash->new( algorithm => 'SHA-1' );
$csh->add(shift);
return $csh->generate;
}
sub store_column {
my ( $self, $column, $value ) = @_;
$value = $self->crypt_password($value)
if ( $column eq "password"
&& defined $value);
return $self->next::method( $column, $value );
}
this will crypt the password each time it is set to a new value. You
have to change crypt_password to fit your needs.
store_column is a dbic method so you have to make sure to call
next::method in there.
moritz
More information about the HTML-FormFu
mailing list