X-Git-Url: http://git.ieval.ro/?a=blobdiff_plain;f=lib%2FGruntmaster%2FData%2FResult%2FUser.pm;h=54e6b52c2527653ddaca9496655f4d8d01533547;hb=526b9e807f925f5a2f58d0b134444755117da83d;hp=21edb48714f09823c83a9affabba870469af136c;hpb=85d3f015cc4e11f00adba9d3a99cb69c7f77156b;p=gruntmaster-data.git diff --git a/lib/Gruntmaster/Data/Result/User.pm b/lib/Gruntmaster/Data/Result/User.pm index 21edb48..54e6b52 100644 --- a/lib/Gruntmaster/Data/Result/User.pm +++ b/lib/Gruntmaster/Data/Result/User.pm @@ -28,6 +28,17 @@ __PACKAGE__->table("users"); data_type: 'text' is_nullable: 0 +=head2 passphrase + + data_type: 'text' + is_nullable: 1 + +=head2 admin + + data_type: 'boolean' + default_value: false + is_nullable: 0 + =head2 name data_type: 'text' @@ -68,6 +79,10 @@ __PACKAGE__->table("users"); __PACKAGE__->add_columns( "id", { data_type => "text", is_nullable => 0 }, + "passphrase", + { data_type => "text", is_nullable => 1 }, + "admin", + { data_type => "boolean", default_value => \"false", is_nullable => 0 }, "name", { data_type => "text", is_nullable => 1 }, "email", @@ -159,9 +174,51 @@ __PACKAGE__->has_many( ); -# Created by DBIx::Class::Schema::Loader v0.07039 @ 2014-03-26 15:24:46 -# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:HjxrnH2QdWGaAnArZpyYMA +# 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 + +=head1 COPYRIGHT AND LICENSE + +Copyright (C) 2014 by Marius Gavrilescu + +This library is free software; you can redistribute it and/or modify +it under the same terms as Perl itself, either Perl version 5.18.1 or, +at your option, any later version of Perl 5 you may have available. + + +=cut