X-Git-Url: http://git.ieval.ro/?a=blobdiff_plain;f=lib%2FGruntmaster%2FData%2FResult%2FUser.pm;h=4922354cfb4061aaade9c0725f3e235b34427ec7;hb=73243865cfa253b09bf1f5c5eddaa2caa38fb2a0;hp=9013946092d7225fe00fe9865795c4dc8f9e9afb;hpb=9bb399215eed61555c05f025aedf6dc53f4e977d;p=gruntmaster-data.git diff --git a/lib/Gruntmaster/Data/Result/User.pm b/lib/Gruntmaster/Data/Result/User.pm index 9013946..4922354 100644 --- a/lib/Gruntmaster/Data/Result/User.pm +++ b/lib/Gruntmaster/Data/Result/User.pm @@ -6,7 +6,7 @@ package Gruntmaster::Data::Result::User; =head1 NAME -Gruntmaster::Data::Result::User +Gruntmaster::Data::Result::User - List of users =cut @@ -33,6 +33,8 @@ __PACKAGE__->table("users"); data_type: 'text' is_nullable: 1 +RFC2307-encoded passphrase + =head2 admin data_type: 'boolean' @@ -44,6 +46,8 @@ __PACKAGE__->table("users"); data_type: 'text' is_nullable: 1 +Full name of user + =head2 email data_type: 'text' @@ -69,11 +73,20 @@ __PACKAGE__->table("users"); data_type: 'text' is_nullable: 1 +Highschool, Undergraduate, Master, Doctorate or Other + +=head2 country + + data_type: 'text' + is_nullable: 1 + =head2 lastjob data_type: 'bigint' is_nullable: 1 +Unix time when this user last submitted a job + =cut __PACKAGE__->add_columns( @@ -95,6 +108,8 @@ __PACKAGE__->add_columns( { data_type => "text", is_nullable => 1 }, "level", { data_type => "text", is_nullable => 1 }, + "country", + { data_type => "text", is_nullable => 1 }, "lastjob", { data_type => "bigint", is_nullable => 1 }, ); @@ -113,6 +128,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 @@ -158,6 +188,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 @@ -174,15 +219,48 @@ __PACKAGE__->has_many( ); -# Created by DBIx::Class::Schema::Loader v0.07039 @ 2014-05-16 15:23:08 -# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:Cho4zmn58Mytf2jHvgP+4g +# Created by DBIx::Class::Schema::Loader v0.07042 @ 2015-01-29 18:45:35 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:rpx697B3St+ICCSbOn4cbQ + +use Class::Method::Modifiers qw/after/; + +after qw/insert update delete/ => sub { + my ($self) = @_; + Gruntmaster::Data::purge '/us/'; + Gruntmaster::Data::purge '/us/' . $self->id; +}; + +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