X-Git-Url: http://git.ieval.ro/?a=blobdiff_plain;f=lib%2FGruntmaster%2FData%2FResult%2FUser.pm;h=c5547c1f776c3b179e54f292600ce7edf26289ad;hb=1de10923aedb415f33631532c45b3589b1fc9f48;hp=740d87a88605e13a360d2b932697f873e92be16f;hpb=4ed3f8e7c64594bb4ea26abb1c4fb51a5a8258d6;p=gruntmaster-data.git diff --git a/lib/Gruntmaster/Data/Result/User.pm b/lib/Gruntmaster/Data/Result/User.pm index 740d87a..c5547c1 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' @@ -38,6 +49,11 @@ __PACKAGE__->table("users"); data_type: 'text' is_nullable: 1 +=head2 phone + + data_type: 'text' + is_nullable: 1 + =head2 town data_type: 'text' @@ -63,10 +79,16 @@ __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", { data_type => "text", is_nullable => 1 }, + "phone", + { data_type => "text", is_nullable => 1 }, "town", { data_type => "text", is_nullable => 1 }, "university", @@ -91,6 +113,21 @@ __PACKAGE__->set_primary_key("id"); =head1 RELATIONS +=head2 contest_statuses + +Type: has_many + +Related object: L + +=cut + +__PACKAGE__->has_many( + "contest_statuses", + "Gruntmaster::Data::Result::ContestStatus", + { "foreign.owner" => "self.id" }, + { cascade_copy => 0, cascade_delete => 0 }, +); + =head2 contests Type: has_many @@ -136,6 +173,21 @@ __PACKAGE__->has_many( { cascade_copy => 0, cascade_delete => 0 }, ); +=head2 problem_statuses + +Type: has_many + +Related object: L + +=cut + +__PACKAGE__->has_many( + "problem_statuses", + "Gruntmaster::Data::Result::ProblemStatus", + { "foreign.owner" => "self.id" }, + { cascade_copy => 0, cascade_delete => 0 }, +); + =head2 problems Type: has_many @@ -152,9 +204,51 @@ __PACKAGE__->has_many( ); -# Created by DBIx::Class::Schema::Loader v0.07039 @ 2014-03-06 12:41:16 -# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:CHRtUlZf3hs+lg6Nqi2LPA +# Created by DBIx::Class::Schema::Loader v0.07042 @ 2014-12-11 23:51:27 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:JcVHC/n8J+NgJge9LkckYA + +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