]>
iEval git - gruntmaster-data.git/blob - lib/Gruntmaster/Data/Result/User.pm
2 package Gruntmaster
::Data
::Result
::User
;
4 # Created by DBIx::Class::Schema::Loader
5 # DO NOT MODIFY THE FIRST PART OF THIS FILE
9 Gruntmaster::Data::Result::User - List of users
16 use base
'DBIx::Class::Core';
18 =head1 TABLE: C<users>
22 __PACKAGE__
->table("users");
36 RFC2307-encoded passphrase
76 Highschool, Undergraduate, Master, Doctorate or Other
88 Unix time when this user last submitted a job
93 default_value: (date_part('epoch'::text, now()))::bigint
96 Unix time when this user was created
100 __PACKAGE__
->add_columns(
102 { data_type
=> "text", is_nullable
=> 0 },
104 { data_type
=> "text", is_nullable
=> 1 },
106 { data_type
=> "boolean", default_value
=> \"false
", is_nullable => 0 },
108 { data_type => "text
", is_nullable => 1 },
110 { data_type => "text
", is_nullable => 1 },
112 { data_type => "text
", is_nullable => 1 },
114 { data_type => "text
", is_nullable => 1 },
116 { data_type => "text
", is_nullable => 1 },
118 { data_type => "text
", is_nullable => 1 },
120 { data_type => "text
", is_nullable => 1 },
122 { data_type => "bigint
", is_nullable => 1 },
125 data_type => "bigint
",
126 default_value => \"(date_part('epoch'::text, now()))::bigint",
141 __PACKAGE__
->set_primary_key("id");
145 =head2 contest_statuses
149 Related object: L<Gruntmaster::Data::Result::ContestStatus>
153 __PACKAGE__
->has_many(
155 "Gruntmaster::Data::Result::ContestStatus",
156 { "foreign.owner" => "self.id" },
157 { cascade_copy
=> 0, cascade_delete
=> 0 },
164 Related object: L<Gruntmaster::Data::Result::Contest>
168 __PACKAGE__
->has_many(
170 "Gruntmaster::Data::Result::Contest",
171 { "foreign.owner" => "self.id" },
172 { cascade_copy
=> 0, cascade_delete
=> 0 },
179 Related object: L<Gruntmaster::Data::Result::Job>
183 __PACKAGE__
->has_many(
185 "Gruntmaster::Data::Result::Job",
186 { "foreign.owner" => "self.id" },
187 { cascade_copy
=> 0, cascade_delete
=> 0 },
194 Related object: L<Gruntmaster::Data::Result::Open>
198 __PACKAGE__
->has_many(
200 "Gruntmaster::Data::Result::Open",
201 { "foreign.owner" => "self.id" },
202 { cascade_copy
=> 0, cascade_delete
=> 0 },
205 =head2 problem_statuses
209 Related object: L<Gruntmaster::Data::Result::ProblemStatus>
213 __PACKAGE__
->has_many(
215 "Gruntmaster::Data::Result::ProblemStatus",
216 { "foreign.owner" => "self.id" },
217 { cascade_copy
=> 0, cascade_delete
=> 0 },
224 Related object: L<Gruntmaster::Data::Result::Problem>
228 __PACKAGE__
->has_many(
230 "Gruntmaster::Data::Result::Problem",
231 { "foreign.owner" => "self.id" },
232 { cascade_copy
=> 0, cascade_delete
=> 0 },
236 # Created by DBIx::Class::Schema::Loader v0.07042 @ 2015-02-10 18:42:04
237 # DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:L/ExLdA0pkJ1DeM+RzlDjw
239 use Bytes
::Random
::Secure qw
/random_bytes/;
240 use Class
::Method
::Modifiers qw
/after/;
241 use Digest
::SHA qw
/hmac_sha1_base64/;
243 after qw
/insert update delete/ => sub {
245 Gruntmaster
::Data
::purge
'/us/';
246 Gruntmaster
::Data
::purge
'/us/' . $self->id;
249 use Authen
::Passphrase
;
250 use Authen
::Passphrase
::BlowfishCrypt
;
252 sub check_passphrase
{
253 my ($self, $pw) = @_;
254 Authen
::Passphrase
->from_rfc2307($self->passphrase)->match($pw)
258 my ($self, $pw) = @_;
259 $self->update({passphrase
=> Authen
::Passphrase
::BlowfishCrypt
->new(
266 my $hmackey = $ENV{GRUNTMASTER_HMAC_KEY
};
268 sub make_reset_hmac
{
269 my ($self, $expire) = @_;
270 $expire //= time + 60 * 60;
271 $hmackey //= random_bytes
512;
272 my $hmac = hmac_sha1_base64
$self->id . " $expire " . $self->passphrase, $hmackey;
273 wantarray ?
($hmac, $expire) : $hmac
282 =head2 check_passphrase(I<$passphrase>)
284 Returns true if I<$passphrase> is the correct passphrase, false otherwise.
286 =head2 set_passphrase(I<$passphrase>)
288 Changes the passphrase to I<$passphrase>.
292 Marius Gavrilescu E<lt>marius@ieval.roE<gt>
294 =head1 COPYRIGHT AND LICENSE
296 Copyright (C) 2014 by Marius Gavrilescu
298 This library is free software; you can redistribute it and/or modify
299 it under the same terms as Perl itself, either Perl version 5.18.1 or,
300 at your option, any later version of Perl 5 you may have available.
This page took 0.075791 seconds and 4 git commands to generate.