X-Git-Url: http://git.ieval.ro/?a=blobdiff_plain;f=lib%2FGruntmaster%2FData%2FResult%2FUser.pm;h=4385b76554c55b5971a0891b40df28a5112f1264;hb=de625c9b0df50de18fdda1c80291760595d38e6e;hp=216447edbdeea407e5438363565ff083d5100719;hpb=4a8747effd02a1e0f9dde86b1c81f6c26ce66f04;p=gruntmaster-data.git diff --git a/lib/Gruntmaster/Data/Result/User.pm b/lib/Gruntmaster/Data/Result/User.pm index 216447e..4385b76 100644 --- a/lib/Gruntmaster/Data/Result/User.pm +++ b/lib/Gruntmaster/Data/Result/User.pm @@ -31,7 +31,7 @@ __PACKAGE__->table("users"); =head2 passphrase data_type: 'text' - is_nullable: 0 + is_nullable: 1 =head2 admin @@ -80,7 +80,7 @@ __PACKAGE__->add_columns( "id", { data_type => "text", is_nullable => 0 }, "passphrase", - { data_type => "text", is_nullable => 0 }, + { data_type => "text", is_nullable => 1 }, "admin", { data_type => "boolean", default_value => \"false", is_nullable => 0 }, "name", @@ -174,15 +174,40 @@ __PACKAGE__->has_many( ); -# Created by DBIx::Class::Schema::Loader v0.07039 @ 2014-04-18 20:16:26 -# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:r7hVLUd+6MeYZn+8I4S7Cw +# Created by DBIx::Class::Schema::Loader v0.07039 @ 2014-05-16 15:23:08 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:Cho4zmn58Mytf2jHvgP+4g + +use Authen::Passphrase; +use Authen::Passphrase::BlowfishCrypt; + +sub check_passphrase { + my ($self, $pw) = @_; + Authen::Passphrase->from_rfc2307($self->passphrase)->match($pw) +} +sub set_passphrase { + my ($self, $pw) = @_; + $self->update({passphrase => Authen::Passphrase::BlowfishCrypt->new( + cost => 10, + passphrase => $pw, + salt_random => 1, + )})->as_rfc2307; +} -# You can replace this text with custom code or comments, and it will be preserved on regeneration 1; __END__ +=head1 METHODS + +=head2 check_passphrase(I<$passphrase>) + +Returns true if I<$passphrase> is the correct passphrase, false otherwise. + +=head2 set_passphrase(I<$passphrase>) + +Changes the passphrase to I<$passphrase>. + =head1 AUTHOR Marius Gavrilescu Emarius@ieval.roE