Purge affected pages on insert/update/delete
[gruntmaster-data.git] / lib / Gruntmaster / Data / Result / User.pm
CommitLineData
4ed3f8e7
MG
1use utf8;
2package Gruntmaster::Data::Result::User;
3
4# Created by DBIx::Class::Schema::Loader
5# DO NOT MODIFY THE FIRST PART OF THIS FILE
6
7=head1 NAME
8
be2f7678 9Gruntmaster::Data::Result::User - List of users
4ed3f8e7
MG
10
11=cut
12
13use strict;
14use warnings;
15
16use base 'DBIx::Class::Core';
17
18=head1 TABLE: C<users>
19
20=cut
21
22__PACKAGE__->table("users");
23
24=head1 ACCESSORS
25
26=head2 id
27
28 data_type: 'text'
29 is_nullable: 0
30
2fec2d56
MG
31=head2 passphrase
32
33 data_type: 'text'
9bb39921 34 is_nullable: 1
2fec2d56 35
be2f7678
MG
36RFC2307-encoded passphrase
37
2fec2d56
MG
38=head2 admin
39
40 data_type: 'boolean'
41 default_value: false
42 is_nullable: 0
43
4ed3f8e7
MG
44=head2 name
45
46 data_type: 'text'
47 is_nullable: 1
48
be2f7678
MG
49Full name of user
50
4ed3f8e7
MG
51=head2 email
52
53 data_type: 'text'
54 is_nullable: 1
55
85d3f015
MG
56=head2 phone
57
58 data_type: 'text'
59 is_nullable: 1
60
4ed3f8e7
MG
61=head2 town
62
63 data_type: 'text'
64 is_nullable: 1
65
66=head2 university
67
68 data_type: 'text'
69 is_nullable: 1
70
71=head2 level
72
73 data_type: 'text'
74 is_nullable: 1
75
be2f7678
MG
76Highschool, Undergraduate, Master, Doctorate or Other
77
4ed3f8e7
MG
78=head2 lastjob
79
80 data_type: 'bigint'
81 is_nullable: 1
82
be2f7678
MG
83Unix time when this user last submitted a job
84
4ed3f8e7
MG
85=cut
86
87__PACKAGE__->add_columns(
88 "id",
89 { data_type => "text", is_nullable => 0 },
2fec2d56 90 "passphrase",
9bb39921 91 { data_type => "text", is_nullable => 1 },
2fec2d56
MG
92 "admin",
93 { data_type => "boolean", default_value => \"false", is_nullable => 0 },
4ed3f8e7
MG
94 "name",
95 { data_type => "text", is_nullable => 1 },
96 "email",
97 { data_type => "text", is_nullable => 1 },
85d3f015
MG
98 "phone",
99 { data_type => "text", is_nullable => 1 },
4ed3f8e7
MG
100 "town",
101 { data_type => "text", is_nullable => 1 },
102 "university",
103 { data_type => "text", is_nullable => 1 },
104 "level",
105 { data_type => "text", is_nullable => 1 },
106 "lastjob",
107 { data_type => "bigint", is_nullable => 1 },
108);
109
110=head1 PRIMARY KEY
111
112=over 4
113
114=item * L</id>
115
116=back
117
118=cut
119
120__PACKAGE__->set_primary_key("id");
121
122=head1 RELATIONS
123
adb42d4d
MG
124=head2 contest_statuses
125
126Type: has_many
127
128Related object: L<Gruntmaster::Data::Result::ContestStatus>
129
130=cut
131
132__PACKAGE__->has_many(
133 "contest_statuses",
134 "Gruntmaster::Data::Result::ContestStatus",
135 { "foreign.owner" => "self.id" },
136 { cascade_copy => 0, cascade_delete => 0 },
137);
138
4ed3f8e7
MG
139=head2 contests
140
141Type: has_many
142
143Related object: L<Gruntmaster::Data::Result::Contest>
144
145=cut
146
147__PACKAGE__->has_many(
148 "contests",
149 "Gruntmaster::Data::Result::Contest",
150 { "foreign.owner" => "self.id" },
151 { cascade_copy => 0, cascade_delete => 0 },
152);
153
154=head2 jobs
155
156Type: has_many
157
158Related object: L<Gruntmaster::Data::Result::Job>
159
160=cut
161
162__PACKAGE__->has_many(
163 "jobs",
164 "Gruntmaster::Data::Result::Job",
165 { "foreign.owner" => "self.id" },
166 { cascade_copy => 0, cascade_delete => 0 },
167);
168
169=head2 opens
170
171Type: has_many
172
173Related object: L<Gruntmaster::Data::Result::Open>
174
175=cut
176
177__PACKAGE__->has_many(
178 "opens",
179 "Gruntmaster::Data::Result::Open",
180 { "foreign.owner" => "self.id" },
181 { cascade_copy => 0, cascade_delete => 0 },
182);
183
adb42d4d
MG
184=head2 problem_statuses
185
186Type: has_many
187
188Related object: L<Gruntmaster::Data::Result::ProblemStatus>
189
190=cut
191
192__PACKAGE__->has_many(
193 "problem_statuses",
194 "Gruntmaster::Data::Result::ProblemStatus",
195 { "foreign.owner" => "self.id" },
196 { cascade_copy => 0, cascade_delete => 0 },
197);
198
4ed3f8e7
MG
199=head2 problems
200
201Type: has_many
202
203Related object: L<Gruntmaster::Data::Result::Problem>
204
205=cut
206
207__PACKAGE__->has_many(
208 "problems",
209 "Gruntmaster::Data::Result::Problem",
210 { "foreign.owner" => "self.id" },
211 { cascade_copy => 0, cascade_delete => 0 },
212);
213
214
be2f7678
MG
215# Created by DBIx::Class::Schema::Loader v0.07042 @ 2014-12-19 16:54:00
216# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:LiA2+ZpTTelwZJtFpZRsbw
4ed3f8e7 217
de7226ca
MG
218use Class::Method::Modifiers qw/after/;
219
220after qw/insert update delete/ => sub {
221 my ($self) = @_;
222 Gruntmaster::Data::purge '/us/';
223 Gruntmaster::Data::purge '/us/' . $self->id;
224};
225
de625c9b
MG
226use Authen::Passphrase;
227use Authen::Passphrase::BlowfishCrypt;
228
229sub check_passphrase {
230 my ($self, $pw) = @_;
231 Authen::Passphrase->from_rfc2307($self->passphrase)->match($pw)
232}
233
234sub set_passphrase {
235 my ($self, $pw) = @_;
236 $self->update({passphrase => Authen::Passphrase::BlowfishCrypt->new(
237 cost => 10,
238 passphrase => $pw,
239 salt_random => 1,
526b9e80 240 )->as_rfc2307});
de625c9b 241}
4ed3f8e7 242
4ed3f8e7 2431;
4a8747ef
MG
244
245__END__
246
de625c9b
MG
247=head1 METHODS
248
249=head2 check_passphrase(I<$passphrase>)
250
251Returns true if I<$passphrase> is the correct passphrase, false otherwise.
252
253=head2 set_passphrase(I<$passphrase>)
254
255Changes the passphrase to I<$passphrase>.
256
4a8747ef
MG
257=head1 AUTHOR
258
259Marius Gavrilescu E<lt>marius@ieval.roE<gt>
260
261=head1 COPYRIGHT AND LICENSE
262
263Copyright (C) 2014 by Marius Gavrilescu
264
265This library is free software; you can redistribute it and/or modify
266it under the same terms as Perl itself, either Perl version 5.18.1 or,
267at your option, any later version of Perl 5 you may have available.
268
269
270=cut
This page took 0.026561 seconds and 4 git commands to generate.