]>
Commit | Line | Data |
---|---|---|
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 | ||
9 | Gruntmaster::Data::Result::User | |
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 | ||
31 | =head2 passphrase | |
32 | ||
33 | data_type: 'text' | |
34 | is_nullable: 1 | |
35 | ||
36 | =head2 admin | |
37 | ||
38 | data_type: 'boolean' | |
39 | default_value: false | |
40 | is_nullable: 0 | |
41 | ||
42 | =head2 name | |
43 | ||
44 | data_type: 'text' | |
45 | is_nullable: 1 | |
46 | ||
47 | =head2 email | |
48 | ||
49 | data_type: 'text' | |
50 | is_nullable: 1 | |
51 | ||
52 | =head2 phone | |
53 | ||
54 | data_type: 'text' | |
55 | is_nullable: 1 | |
56 | ||
57 | =head2 town | |
58 | ||
59 | data_type: 'text' | |
60 | is_nullable: 1 | |
61 | ||
62 | =head2 university | |
63 | ||
64 | data_type: 'text' | |
65 | is_nullable: 1 | |
66 | ||
67 | =head2 level | |
68 | ||
69 | data_type: 'text' | |
70 | is_nullable: 1 | |
71 | ||
72 | =head2 lastjob | |
73 | ||
74 | data_type: 'bigint' | |
75 | is_nullable: 1 | |
76 | ||
77 | =cut | |
78 | ||
79 | __PACKAGE__->add_columns( | |
80 | "id", | |
81 | { data_type => "text", is_nullable => 0 }, | |
82 | "passphrase", | |
83 | { data_type => "text", is_nullable => 1 }, | |
84 | "admin", | |
85 | { data_type => "boolean", default_value => \"false", is_nullable => 0 }, | |
86 | "name", | |
87 | { data_type => "text", is_nullable => 1 }, | |
88 | "email", | |
89 | { data_type => "text", is_nullable => 1 }, | |
90 | "phone", | |
91 | { data_type => "text", is_nullable => 1 }, | |
92 | "town", | |
93 | { data_type => "text", is_nullable => 1 }, | |
94 | "university", | |
95 | { data_type => "text", is_nullable => 1 }, | |
96 | "level", | |
97 | { data_type => "text", is_nullable => 1 }, | |
98 | "lastjob", | |
99 | { data_type => "bigint", is_nullable => 1 }, | |
100 | ); | |
101 | ||
102 | =head1 PRIMARY KEY | |
103 | ||
104 | =over 4 | |
105 | ||
106 | =item * L</id> | |
107 | ||
108 | =back | |
109 | ||
110 | =cut | |
111 | ||
112 | __PACKAGE__->set_primary_key("id"); | |
113 | ||
114 | =head1 RELATIONS | |
115 | ||
116 | =head2 contests | |
117 | ||
118 | Type: has_many | |
119 | ||
120 | Related object: L<Gruntmaster::Data::Result::Contest> | |
121 | ||
122 | =cut | |
123 | ||
124 | __PACKAGE__->has_many( | |
125 | "contests", | |
126 | "Gruntmaster::Data::Result::Contest", | |
127 | { "foreign.owner" => "self.id" }, | |
128 | { cascade_copy => 0, cascade_delete => 0 }, | |
129 | ); | |
130 | ||
131 | =head2 jobs | |
132 | ||
133 | Type: has_many | |
134 | ||
135 | Related object: L<Gruntmaster::Data::Result::Job> | |
136 | ||
137 | =cut | |
138 | ||
139 | __PACKAGE__->has_many( | |
140 | "jobs", | |
141 | "Gruntmaster::Data::Result::Job", | |
142 | { "foreign.owner" => "self.id" }, | |
143 | { cascade_copy => 0, cascade_delete => 0 }, | |
144 | ); | |
145 | ||
146 | =head2 opens | |
147 | ||
148 | Type: has_many | |
149 | ||
150 | Related object: L<Gruntmaster::Data::Result::Open> | |
151 | ||
152 | =cut | |
153 | ||
154 | __PACKAGE__->has_many( | |
155 | "opens", | |
156 | "Gruntmaster::Data::Result::Open", | |
157 | { "foreign.owner" => "self.id" }, | |
158 | { cascade_copy => 0, cascade_delete => 0 }, | |
159 | ); | |
160 | ||
161 | =head2 problems | |
162 | ||
163 | Type: has_many | |
164 | ||
165 | Related object: L<Gruntmaster::Data::Result::Problem> | |
166 | ||
167 | =cut | |
168 | ||
169 | __PACKAGE__->has_many( | |
170 | "problems", | |
171 | "Gruntmaster::Data::Result::Problem", | |
172 | { "foreign.owner" => "self.id" }, | |
173 | { cascade_copy => 0, cascade_delete => 0 }, | |
174 | ); | |
175 | ||
176 | ||
177 | # Created by DBIx::Class::Schema::Loader v0.07039 @ 2014-05-16 15:23:08 | |
178 | # DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:Cho4zmn58Mytf2jHvgP+4g | |
179 | ||
180 | use Authen::Passphrase; | |
181 | use Authen::Passphrase::BlowfishCrypt; | |
182 | ||
183 | sub check_passphrase { | |
184 | my ($self, $pw) = @_; | |
185 | Authen::Passphrase->from_rfc2307($self->passphrase)->match($pw) | |
186 | } | |
187 | ||
188 | sub set_passphrase { | |
189 | my ($self, $pw) = @_; | |
190 | $self->update({passphrase => Authen::Passphrase::BlowfishCrypt->new( | |
191 | cost => 10, | |
192 | passphrase => $pw, | |
193 | salt_random => 1, | |
194 | )})->as_rfc2307; | |
195 | } | |
196 | ||
197 | 1; | |
198 | ||
199 | __END__ | |
200 | ||
201 | =head1 METHODS | |
202 | ||
203 | =head2 check_passphrase(I<$passphrase>) | |
204 | ||
205 | Returns true if I<$passphrase> is the correct passphrase, false otherwise. | |
206 | ||
207 | =head2 set_passphrase(I<$passphrase>) | |
208 | ||
209 | Changes the passphrase to I<$passphrase>. | |
210 | ||
211 | =head1 AUTHOR | |
212 | ||
213 | Marius Gavrilescu E<lt>marius@ieval.roE<gt> | |
214 | ||
215 | =head1 COPYRIGHT AND LICENSE | |
216 | ||
217 | Copyright (C) 2014 by Marius Gavrilescu | |
218 | ||
219 | This library is free software; you can redistribute it and/or modify | |
220 | it under the same terms as Perl itself, either Perl version 5.18.1 or, | |
221 | at your option, any later version of Perl 5 you may have available. | |
222 | ||
223 | ||
224 | =cut |