| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package RapidApp::CoreSchema::Result::User; |
|
2
|
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
604
|
use strict; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
29
|
|
|
4
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
24
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
4
|
use Moose; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
6
|
|
|
7
|
1
|
|
|
1
|
|
5667
|
use MooseX::NonMoose; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
8
|
|
|
8
|
1
|
|
|
1
|
|
4578
|
use namespace::autoclean; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
11
|
|
|
9
|
|
|
|
|
|
|
extends 'DBIx::Class::Core'; |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
#use DBIx::Class::PassphraseColumn 0.02; |
|
12
|
1
|
|
|
1
|
|
497
|
use RapidApp::DBIC::Component::PassphraseColumn; # temp |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
297
|
|
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
__PACKAGE__->load_components( |
|
15
|
|
|
|
|
|
|
"InflateColumn::DateTime", |
|
16
|
|
|
|
|
|
|
#"PassphraseColumn", |
|
17
|
|
|
|
|
|
|
'+RapidApp::DBIC::Component::PassphraseColumn' |
|
18
|
|
|
|
|
|
|
); |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
__PACKAGE__->table('user'); |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
__PACKAGE__->add_columns( |
|
23
|
|
|
|
|
|
|
"id", |
|
24
|
|
|
|
|
|
|
{ |
|
25
|
|
|
|
|
|
|
data_type => "integer", |
|
26
|
|
|
|
|
|
|
extra => { unsigned => 1 }, |
|
27
|
|
|
|
|
|
|
is_auto_increment => 1, |
|
28
|
|
|
|
|
|
|
is_nullable => 0, |
|
29
|
|
|
|
|
|
|
}, |
|
30
|
|
|
|
|
|
|
"username", |
|
31
|
|
|
|
|
|
|
{ data_type => "varchar", is_nullable => 0, size => 32 }, |
|
32
|
|
|
|
|
|
|
#"password", |
|
33
|
|
|
|
|
|
|
#{ data_type => "varchar", is_nullable => 1, size => 255 }, |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
password => { |
|
36
|
|
|
|
|
|
|
is_serializable => 1, |
|
37
|
|
|
|
|
|
|
data_type => 'varchar', |
|
38
|
|
|
|
|
|
|
is_nullable => 1, |
|
39
|
|
|
|
|
|
|
size => 'max', |
|
40
|
|
|
|
|
|
|
passphrase => 'rfc2307', |
|
41
|
|
|
|
|
|
|
passphrase_class => 'BlowfishCrypt', |
|
42
|
|
|
|
|
|
|
passphrase_args => { |
|
43
|
|
|
|
|
|
|
cost => 9, |
|
44
|
|
|
|
|
|
|
salt_random => 1, |
|
45
|
|
|
|
|
|
|
}, |
|
46
|
|
|
|
|
|
|
passphrase_check_method => 'check_password', |
|
47
|
|
|
|
|
|
|
}, |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
"full_name", |
|
50
|
|
|
|
|
|
|
{ data_type => "varchar", is_nullable => 1, size => 255 }, |
|
51
|
|
|
|
|
|
|
"last_login_ts", |
|
52
|
|
|
|
|
|
|
{ |
|
53
|
|
|
|
|
|
|
data_type => "datetime", |
|
54
|
|
|
|
|
|
|
datetime_undef_if_invalid => 1, |
|
55
|
|
|
|
|
|
|
is_nullable => 1, |
|
56
|
|
|
|
|
|
|
}, |
|
57
|
|
|
|
|
|
|
"disabled", |
|
58
|
|
|
|
|
|
|
{ data_type => "tinyint", default_value => 0, is_nullable => 0 }, |
|
59
|
|
|
|
|
|
|
"disabled_ts", |
|
60
|
|
|
|
|
|
|
{ |
|
61
|
|
|
|
|
|
|
data_type => "datetime", |
|
62
|
|
|
|
|
|
|
datetime_undef_if_invalid => 1, |
|
63
|
|
|
|
|
|
|
is_nullable => 1, |
|
64
|
|
|
|
|
|
|
}, |
|
65
|
|
|
|
|
|
|
); |
|
66
|
|
|
|
|
|
|
__PACKAGE__->set_primary_key("id"); |
|
67
|
|
|
|
|
|
|
__PACKAGE__->add_unique_constraint("username", ["username"]); |
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
__PACKAGE__->has_many( |
|
70
|
|
|
|
|
|
|
"user_to_roles", |
|
71
|
|
|
|
|
|
|
"RapidApp::CoreSchema::Result::UserToRole", |
|
72
|
|
|
|
|
|
|
{ "foreign.username" => "self.username" }, |
|
73
|
|
|
|
|
|
|
{ cascade_copy => 0, cascade_delete => 0 }, |
|
74
|
|
|
|
|
|
|
); |
|
75
|
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
__PACKAGE__->has_many( |
|
77
|
|
|
|
|
|
|
"saved_states", |
|
78
|
|
|
|
|
|
|
"RapidApp::CoreSchema::Result::SavedState", |
|
79
|
|
|
|
|
|
|
{ "foreign.user_id" => "self.id" }, |
|
80
|
|
|
|
|
|
|
{ cascade_copy => 0, cascade_delete => 0 }, |
|
81
|
|
|
|
|
|
|
); |
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
__PACKAGE__->has_many( |
|
84
|
|
|
|
|
|
|
"sessions", |
|
85
|
|
|
|
|
|
|
"RapidApp::CoreSchema::Result::Session", |
|
86
|
|
|
|
|
|
|
{ "foreign.user_id" => "self.id" }, |
|
87
|
|
|
|
|
|
|
{ cascade_copy => 0, cascade_delete => 0 }, |
|
88
|
|
|
|
|
|
|
); |
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
__PACKAGE__->load_components('+RapidApp::DBIC::Component::TableSpec'); |
|
92
|
|
|
|
|
|
|
__PACKAGE__->TableSpec_m2m( roles => "user_to_roles", 'role'); |
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
# ---- |
|
95
|
|
|
|
|
|
|
# TODO/FIXME: This is ugly/global, but works. This virtual column |
|
96
|
|
|
|
|
|
|
# provides a column-based interface to set the password, optionally |
|
97
|
|
|
|
|
|
|
# passing it through a custom Authen::Passphrase class. The ugly |
|
98
|
|
|
|
|
|
|
# part is that the Authen::Passphrase class setting is set on the class... |
|
99
|
|
|
|
|
|
|
# This is being set by Catalyst::Plugin::RapidApp::AuthCore |
|
100
|
|
|
|
|
|
|
__PACKAGE__->mk_classdata( 'authen_passphrase_class' ); |
|
101
|
|
|
|
|
|
|
__PACKAGE__->mk_classdata( 'authen_passphrase_params' ); |
|
102
|
|
|
|
|
|
|
__PACKAGE__->add_virtual_columns( set_pw => { |
|
103
|
|
|
|
|
|
|
data_type => "varchar", |
|
104
|
|
|
|
|
|
|
is_nullable => 1, |
|
105
|
|
|
|
|
|
|
sql => "SELECT NULL", |
|
106
|
|
|
|
|
|
|
set_function => sub { |
|
107
|
|
|
|
|
|
|
my ($self,$pw) = @_; |
|
108
|
|
|
|
|
|
|
if($pw && $pw ne '') { |
|
109
|
|
|
|
|
|
|
if($self->authen_passphrase_class) { |
|
110
|
|
|
|
|
|
|
my %params = ( |
|
111
|
|
|
|
|
|
|
%{ $self->authen_passphrase_params || {} }, |
|
112
|
|
|
|
|
|
|
passphrase => $pw |
|
113
|
|
|
|
|
|
|
); |
|
114
|
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
$pw = $self->authen_passphrase_class->new(%params); |
|
116
|
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
# TODO/FIXME: I thought I could pass an Authen::Passphrase object |
|
118
|
|
|
|
|
|
|
# to the PassphraseColumn, but it seemed to always only create the |
|
119
|
|
|
|
|
|
|
# default set in passphrase_class, so I am just doing it manually |
|
120
|
|
|
|
|
|
|
my $pf = $pw->can('as_rfc2307') |
|
121
|
|
|
|
|
|
|
? $pw->as_rfc2307 : join('','{CRYPT}',$pw->as_crypt); |
|
122
|
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
$self->store_column( password => $pf ); |
|
124
|
|
|
|
|
|
|
$self->make_column_dirty('password'); |
|
125
|
|
|
|
|
|
|
} |
|
126
|
|
|
|
|
|
|
else { |
|
127
|
|
|
|
|
|
|
$self->password($pw); |
|
128
|
|
|
|
|
|
|
} |
|
129
|
|
|
|
|
|
|
$self->update; |
|
130
|
|
|
|
|
|
|
} |
|
131
|
|
|
|
|
|
|
} |
|
132
|
|
|
|
|
|
|
}); |
|
133
|
|
|
|
|
|
|
# ---- |
|
134
|
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
__PACKAGE__->apply_TableSpec; |
|
136
|
|
|
|
|
|
|
|
|
137
|
1
|
|
|
1
|
|
7
|
use RapidApp::Util qw(:all); |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
807
|
|
|
138
|
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
# Always returns undef unless 'linked_user_model' is configured |
|
140
|
|
|
|
|
|
|
sub linkedRow { |
|
141
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
|
142
|
0
|
|
0
|
|
|
0
|
$self->{_linkedRow} //= do { |
|
143
|
0
|
|
|
|
|
0
|
my $Row = undef; |
|
144
|
0
|
0
|
|
|
|
0
|
if($self->can('_find_linkedRow')) { |
|
145
|
0
|
|
0
|
|
|
0
|
$Row = $self->_find_linkedRow || $self->_create_linkedRow; |
|
146
|
|
|
|
|
|
|
} |
|
147
|
|
|
|
|
|
|
$Row |
|
148
|
0
|
|
|
|
|
0
|
} |
|
149
|
|
|
|
|
|
|
} |
|
150
|
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
sub update { |
|
153
|
11
|
|
|
11
|
1
|
2171
|
my $self = shift; |
|
154
|
11
|
|
|
|
|
32
|
my $columns = shift; |
|
155
|
11
|
100
|
|
|
|
390
|
$self->set_inflated_columns($columns) if ($columns); |
|
156
|
|
|
|
|
|
|
|
|
157
|
11
|
|
|
|
|
1234
|
my $username_change = $self->is_column_changed('username'); |
|
158
|
11
|
|
|
|
|
105
|
my $password_change = $self->is_column_changed('password'); |
|
159
|
|
|
|
|
|
|
|
|
160
|
11
|
|
|
|
|
90
|
$self->next::method; |
|
161
|
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
# When a username is changed, update all active sessions with the new |
|
163
|
|
|
|
|
|
|
# username. This allows current sessions to seamlessly keep working |
|
164
|
11
|
50
|
|
|
|
42
|
if($username_change) { |
|
165
|
0
|
|
|
|
|
0
|
my $epoch = time; |
|
166
|
|
|
|
|
|
|
$_->set_encoded_session_keys({ |
|
167
|
|
|
|
|
|
|
RapidApp_username => $self->username, |
|
168
|
|
|
|
|
|
|
__updated => $epoch, |
|
169
|
|
|
|
|
|
|
__user => { $self->get_columns } |
|
170
|
0
|
|
|
|
|
0
|
})->update for ($self->sessions->all); |
|
171
|
|
|
|
|
|
|
} |
|
172
|
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
# When the password is changed, invalidate all current sessions *except* |
|
174
|
|
|
|
|
|
|
# the session of the user making the change, when they are changing their |
|
175
|
|
|
|
|
|
|
# own password. This means that changing a user password instantly terminates |
|
176
|
|
|
|
|
|
|
# their access to the system, even if they are already logged in |
|
177
|
11
|
100
|
|
|
|
39
|
if($password_change) { |
|
178
|
3
|
|
|
|
|
72
|
my $Rs = $self->sessions; |
|
179
|
|
|
|
|
|
|
|
|
180
|
3
|
100
|
|
|
|
4476
|
if(my $c = RapidApp->active_request_context) { |
|
181
|
2
|
|
|
|
|
18
|
$Rs = $Rs->search_rs({ |
|
182
|
|
|
|
|
|
|
'me.id' => { '!=' => join(':','session',$c->sessionid) } |
|
183
|
|
|
|
|
|
|
}); |
|
184
|
|
|
|
|
|
|
} |
|
185
|
|
|
|
|
|
|
|
|
186
|
3
|
|
|
|
|
1497
|
$_->set_expires(0)->update for ($Rs->all); |
|
187
|
|
|
|
|
|
|
} |
|
188
|
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
$self |
|
191
|
11
|
|
|
|
|
6121
|
} |
|
192
|
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
__PACKAGE__->TableSpec_set_conf( |
|
196
|
|
|
|
|
|
|
title => 'User', |
|
197
|
|
|
|
|
|
|
title_multi => 'Users', |
|
198
|
|
|
|
|
|
|
iconCls => 'ra-icon-businessman', |
|
199
|
|
|
|
|
|
|
multiIconCls => 'ra-icon-businessmen', |
|
200
|
|
|
|
|
|
|
display_column => 'username', |
|
201
|
|
|
|
|
|
|
priority_rel_columns => 1, |
|
202
|
|
|
|
|
|
|
columns => { |
|
203
|
|
|
|
|
|
|
id => { width => 40, header => 'Id', profiles => ['noedit'] }, |
|
204
|
|
|
|
|
|
|
username => { width => 90, header => 'Username' }, |
|
205
|
|
|
|
|
|
|
password => { width => 120, header => 'Password (hashed)', profiles => ['noedit'] }, |
|
206
|
|
|
|
|
|
|
full_name => { width => 120, header => 'Full Name', hidden => \1 }, |
|
207
|
|
|
|
|
|
|
|
|
208
|
|
|
|
|
|
|
last_login_ts => { |
|
209
|
|
|
|
|
|
|
hidden => \1, # temp: hide only so it doesn't show between password and set_pw |
|
210
|
|
|
|
|
|
|
header => 'Last Login', |
|
211
|
|
|
|
|
|
|
width => 120, allow_edit => \0, allow_add => \0 |
|
212
|
|
|
|
|
|
|
}, |
|
213
|
|
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
disabled => { |
|
215
|
|
|
|
|
|
|
width => 60, profiles => ['bool'], hidden => \1, |
|
216
|
|
|
|
|
|
|
# Not implemented yet |
|
217
|
|
|
|
|
|
|
no_column => \1, no_quick_search => \1, no_multifilter => \1 |
|
218
|
|
|
|
|
|
|
}, |
|
219
|
|
|
|
|
|
|
|
|
220
|
|
|
|
|
|
|
disabled_ts => { |
|
221
|
|
|
|
|
|
|
width => 120, hidden => \1, |
|
222
|
|
|
|
|
|
|
# Not implemented yet |
|
223
|
|
|
|
|
|
|
no_column => \1, no_quick_search => \1, no_multifilter => \1 |
|
224
|
|
|
|
|
|
|
}, |
|
225
|
|
|
|
|
|
|
|
|
226
|
|
|
|
|
|
|
|
|
227
|
|
|
|
|
|
|
|
|
228
|
|
|
|
|
|
|
roles => { width => 220, header => 'Roles' }, |
|
229
|
|
|
|
|
|
|
sessions => { width => 120, header => 'Sessions' }, |
|
230
|
|
|
|
|
|
|
saved_states => { width => 130, header => 'Saved Views' }, |
|
231
|
|
|
|
|
|
|
user_to_roles => { width => 130, header => 'User to Roles', hidden => \1 }, |
|
232
|
|
|
|
|
|
|
|
|
233
|
|
|
|
|
|
|
set_pw => { |
|
234
|
|
|
|
|
|
|
header => 'Set Password*', |
|
235
|
|
|
|
|
|
|
width => 130, |
|
236
|
|
|
|
|
|
|
editor => { xtype => 'ra-change-password-field' }, |
|
237
|
|
|
|
|
|
|
renderer => 'Ext.ux.RapidApp.renderSetPwValue' |
|
238
|
|
|
|
|
|
|
}, |
|
239
|
|
|
|
|
|
|
|
|
240
|
|
|
|
|
|
|
} |
|
241
|
|
|
|
|
|
|
); |
|
242
|
|
|
|
|
|
|
|
|
243
|
|
|
|
|
|
|
|
|
244
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
|
245
|
|
|
|
|
|
|
1; |