| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Catalyst::Authentication::Store::DBI::ButMaintained::User; |
|
2
|
1
|
|
|
1
|
|
4928
|
use strict; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
31
|
|
|
3
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
25
|
|
|
4
|
1
|
|
|
1
|
|
4
|
use namespace::autoclean; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
5
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
295
|
use Moose; |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
extends 'Catalyst::Authentication::User'; |
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
has 'store' => ( |
|
10
|
|
|
|
|
|
|
isa => 'Object' |
|
11
|
|
|
|
|
|
|
, is => 'ro' |
|
12
|
|
|
|
|
|
|
, required => 1 |
|
13
|
|
|
|
|
|
|
, handles => [qw/get_config _safe_escape/] |
|
14
|
|
|
|
|
|
|
); |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
has 'authinfo' => ( isa => 'HashRef', is => 'ro', required => 1 ); |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
has 'user' => ( |
|
19
|
|
|
|
|
|
|
isa => 'HashRef' |
|
20
|
|
|
|
|
|
|
, is => 'ro' |
|
21
|
|
|
|
|
|
|
, required => 1 |
|
22
|
|
|
|
|
|
|
, traits => ['Hash'] |
|
23
|
|
|
|
|
|
|
, handles => { 'get' => 'get' } |
|
24
|
|
|
|
|
|
|
); |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
## Currently requires user-role to be joined on single key |
|
27
|
|
|
|
|
|
|
## TODO If we have user_role_table, and role_table AND role_key behave old way |
|
28
|
|
|
|
|
|
|
## Provide option to have no role_table, and to handle composite key roles |
|
29
|
|
|
|
|
|
|
## Append the conditionals in find_user |
|
30
|
|
|
|
|
|
|
## Current workaround is to just subclass this and override the default |
|
31
|
|
|
|
|
|
|
## Now possible with store_user_class |
|
32
|
|
|
|
|
|
|
has 'dbi_model' => ( isa => 'Object', is => 'ro' ); |
|
33
|
|
|
|
|
|
|
has 'roles' => ( |
|
34
|
|
|
|
|
|
|
isa => 'ArrayRef' |
|
35
|
|
|
|
|
|
|
, is => 'ro' |
|
36
|
|
|
|
|
|
|
, auto_deref => 1 |
|
37
|
|
|
|
|
|
|
, lazy => 1 |
|
38
|
|
|
|
|
|
|
, default => sub { |
|
39
|
|
|
|
|
|
|
my $self = shift; |
|
40
|
|
|
|
|
|
|
my $dbh = $self->dbi_model->dbh; |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
my @field = ( |
|
43
|
|
|
|
|
|
|
'role_table', 'role_name', |
|
44
|
|
|
|
|
|
|
'role_table', |
|
45
|
|
|
|
|
|
|
'user_role_table', |
|
46
|
|
|
|
|
|
|
'user_role_table', 'user_role_role_key', |
|
47
|
|
|
|
|
|
|
'role_table', 'role_key', |
|
48
|
|
|
|
|
|
|
'user_role_table', 'user_role_user_key' |
|
49
|
|
|
|
|
|
|
); |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
my $sql = sprintf( |
|
52
|
|
|
|
|
|
|
'SELECT %s.%s FROM %s ' |
|
53
|
|
|
|
|
|
|
. 'INNER JOIN %s ON %s.%s = %s.%s ' |
|
54
|
|
|
|
|
|
|
. 'WHERE %s.%s = ?' |
|
55
|
|
|
|
|
|
|
, map { $dbh->quote_identifier($self->get_config($_)) } @field |
|
56
|
|
|
|
|
|
|
); |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
my $sth = $dbh->prepare_cached($sql) or die($dbh->errstr()); |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
my $role; |
|
61
|
|
|
|
|
|
|
$sth->execute( $self->get($self->get_config('user_key')) ) or die($dbh->errstr()); |
|
62
|
|
|
|
|
|
|
$sth->bind_columns(\$role) or die($dbh->errstr()); |
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
my @roles; |
|
65
|
|
|
|
|
|
|
while ($sth->fetch()) { |
|
66
|
|
|
|
|
|
|
push @roles, $role; |
|
67
|
|
|
|
|
|
|
} |
|
68
|
|
|
|
|
|
|
$sth->finish(); |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
return \@roles; |
|
71
|
|
|
|
|
|
|
} |
|
72
|
|
|
|
|
|
|
); |
|
73
|
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
sub id { |
|
75
|
|
|
|
|
|
|
my $self = shift; |
|
76
|
|
|
|
|
|
|
return $self->get( $self->get_config('user_key') ); |
|
77
|
|
|
|
|
|
|
} |
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
# sub supports is implemented by the base class, so supported_features is enough |
|
80
|
|
|
|
|
|
|
sub supported_features { +{ session => 1, roles => 1 } } |
|
81
|
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
sub BUILDARGS { |
|
83
|
|
|
|
|
|
|
my $class = shift; |
|
84
|
|
|
|
|
|
|
my ( $store, $user ) = @_; |
|
85
|
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
scalar @_ == 1 |
|
87
|
|
|
|
|
|
|
? $class->SUPER::BUILDARGS(@_) |
|
88
|
|
|
|
|
|
|
: { store => $store, user => $user } |
|
89
|
|
|
|
|
|
|
; |
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
} |
|
92
|
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
## These are used in the base class for defaults |
|
95
|
|
|
|
|
|
|
## Deprecated |
|
96
|
|
|
|
|
|
|
sub get_object { +shift->user } |
|
97
|
|
|
|
|
|
|
## Deprecated |
|
98
|
|
|
|
|
|
|
sub obj { +shift->user } |
|
99
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
1; |
|
101
|
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
__END__ |
|
103
|
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=head1 NAME |
|
105
|
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
Catalyst::Authentication::Store::DBI::ButMaintained::User - User object representing a database record |
|
107
|
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
109
|
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
This class represents users found in the database and implements methods to access the contained information. |
|
111
|
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
=head1 METHODS |
|
113
|
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=head2 new({ store => $objRef, user => $sth->fetchrow_hashref, auth_info => $hashRef, $dbi_model => $objRef }) |
|
115
|
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=head3 Attributes |
|
117
|
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
=over 4 |
|
119
|
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=item store |
|
121
|
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
Internal reference to the store. |
|
123
|
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
=item user |
|
125
|
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
Hash ref of the row from the database, what calls to C<get> read. |
|
127
|
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
=item auth_info |
|
129
|
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
Original hash ref supplied to C<find_user> |
|
131
|
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
=item dbi_model |
|
133
|
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
Required so it can retreive roles, in the future. |
|
135
|
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
=back |
|
137
|
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
=head2 id |
|
139
|
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
=head2 supported_features |
|
141
|
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
=head2 get |
|
143
|
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
=head2 user |
|
145
|
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
This method returns the original hash ref returned by the DB. |
|
147
|
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
=head2 get_object |
|
149
|
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
I<DEPRECATED> use C<user> instead |
|
151
|
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
=head2 obj |
|
153
|
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
I<DEPRECATED> use C<user> instead |
|
155
|
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
=head2 roles |
|
157
|
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
159
|
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
=over 4 |
|
161
|
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
=item L<Catalyst::Authentication::Store::DBI::ButMaintained> |
|
163
|
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
=back |
|
165
|
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
=head1 AUTHOR |
|
167
|
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
Evan Carroll E<lt>cpan@evancarroll.comE<gt> |
|
169
|
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
(old) Simon Bertrang, E<lt>simon.bertrang@puzzworks.comE<gt> |
|
171
|
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
=head1 COPYRIGHT |
|
173
|
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
Copyright (c) 2010 Evan Carroll, L<http://www.evancarroll.com/> |
|
175
|
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
Copyright (c) 2008 PuzzWorks OHG, L<http://puzzworks.com/> |
|
177
|
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
=head1 LICENSE |
|
179
|
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify it under |
|
181
|
|
|
|
|
|
|
the same terms as Perl itself. |