]>
Commit | Line | Data |
---|---|---|
4ed3f8e7 MG |
1 | use utf8; |
2 | package 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 | 9 | Gruntmaster::Data::Result::User - List of users |
4ed3f8e7 MG |
10 | |
11 | =cut | |
12 | ||
13 | use strict; | |
14 | use warnings; | |
15 | ||
16 | use 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 |
36 | RFC2307-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 |
49 | Full 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 |
76 | Highschool, Undergraduate, Master, Doctorate or Other |
77 | ||
4ed3f8e7 MG |
78 | =head2 lastjob |
79 | ||
80 | data_type: 'bigint' | |
81 | is_nullable: 1 | |
82 | ||
be2f7678 MG |
83 | Unix 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 | ||
126 | Type: has_many | |
127 | ||
128 | Related 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 | ||
141 | Type: has_many | |
142 | ||
143 | Related 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 | ||
156 | Type: has_many | |
157 | ||
158 | Related 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 | ||
171 | Type: has_many | |
172 | ||
173 | Related 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 | ||
186 | Type: has_many | |
187 | ||
188 | Related 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 | ||
201 | Type: has_many | |
202 | ||
203 | Related 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 | |
de625c9b MG |
218 | use Authen::Passphrase; |
219 | use Authen::Passphrase::BlowfishCrypt; | |
220 | ||
221 | sub check_passphrase { | |
222 | my ($self, $pw) = @_; | |
223 | Authen::Passphrase->from_rfc2307($self->passphrase)->match($pw) | |
224 | } | |
225 | ||
226 | sub set_passphrase { | |
227 | my ($self, $pw) = @_; | |
228 | $self->update({passphrase => Authen::Passphrase::BlowfishCrypt->new( | |
229 | cost => 10, | |
230 | passphrase => $pw, | |
231 | salt_random => 1, | |
526b9e80 | 232 | )->as_rfc2307}); |
de625c9b | 233 | } |
4ed3f8e7 | 234 | |
4ed3f8e7 | 235 | 1; |
4a8747ef MG |
236 | |
237 | __END__ | |
238 | ||
de625c9b MG |
239 | =head1 METHODS |
240 | ||
241 | =head2 check_passphrase(I<$passphrase>) | |
242 | ||
243 | Returns true if I<$passphrase> is the correct passphrase, false otherwise. | |
244 | ||
245 | =head2 set_passphrase(I<$passphrase>) | |
246 | ||
247 | Changes the passphrase to I<$passphrase>. | |
248 | ||
4a8747ef MG |
249 | =head1 AUTHOR |
250 | ||
251 | Marius Gavrilescu E<lt>marius@ieval.roE<gt> | |
252 | ||
253 | =head1 COPYRIGHT AND LICENSE | |
254 | ||
255 | Copyright (C) 2014 by Marius Gavrilescu | |
256 | ||
257 | This library is free software; you can redistribute it and/or modify | |
258 | it under the same terms as Perl itself, either Perl version 5.18.1 or, | |
259 | at your option, any later version of Perl 5 you may have available. | |
260 | ||
261 | ||
262 | =cut |