line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Catalyst::Authentication::Store::Tangram::User; |
2
|
1
|
|
|
1
|
|
6
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
32
|
|
3
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
24
|
|
4
|
1
|
|
|
1
|
|
5
|
use base qw/Catalyst::Authentication::User/; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
807
|
|
5
|
|
|
|
|
|
|
use Carp qw/confess/; |
6
|
|
|
|
|
|
|
use Scalar::Util qw/blessed/; |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
use overload '""' => sub { shift->id }, fallback => 1; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
BEGIN { |
11
|
|
|
|
|
|
|
__PACKAGE__->mk_accessors(qw/_tangram _storage _store _roles/); |
12
|
|
|
|
|
|
|
} |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub new { |
15
|
|
|
|
|
|
|
my ($class, $storage, $tangram_ob, $store) = @_; |
16
|
|
|
|
|
|
|
bless { _storage => $storage, _tangram => $tangram_ob, _store => $store }, $class; |
17
|
|
|
|
|
|
|
} |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
*get_object = \&_tangram; |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub id { |
22
|
|
|
|
|
|
|
my ($self) = @_; |
23
|
|
|
|
|
|
|
return $self->_storage->id($self->_tangram); |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub roles { |
27
|
|
|
|
|
|
|
my ($self) = @_; |
28
|
|
|
|
|
|
|
$self->_roles([$self->_store->lookup_roles($self)]) |
29
|
|
|
|
|
|
|
unless $self->_roles; |
30
|
|
|
|
|
|
|
return @{ $self->_roles }; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub supported_features { |
34
|
|
|
|
|
|
|
return { |
35
|
|
|
|
|
|
|
password => { self_check => 0, }, |
36
|
|
|
|
|
|
|
session => 1, |
37
|
|
|
|
|
|
|
roles => { self_check => 0, }, |
38
|
|
|
|
|
|
|
}; |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub AUTOLOAD { |
42
|
|
|
|
|
|
|
my $self = shift; |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
( my $method ) = ( our $AUTOLOAD =~ /([^:]+)$/ ); |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
return if $method eq "DESTROY"; |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
confess("Could not call method $method on tangram class " . |
49
|
|
|
|
|
|
|
blessed($self->_tangram)) unless $self->_tangram->can($method); |
50
|
|
|
|
|
|
|
$self->_tangram->$method; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
1; |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=head1 NAME |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
Catalyst::Authentication::Store::Tangram::User - A thin adaptor |
58
|
|
|
|
|
|
|
to adapt any Tangram class to behave as needed by |
59
|
|
|
|
|
|
|
L<Catalyst::Authentication::User> |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=head1 SYNOPSIS |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
$c->user->id; # Returns unique user ID |
64
|
|
|
|
|
|
|
$c->user->get('email_address'); # Retrieve value from the underlying Tangram object. |
65
|
|
|
|
|
|
|
$c->user->get_object; # Get the underlying Tangram object yourself. |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=head1 DESCRIPTION |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
The Catalyst::Authentication::Store::Tangram::User class encapsulates any |
70
|
|
|
|
|
|
|
Tangram class in the L<Catalyst::Authentication::User> interface. An instance |
71
|
|
|
|
|
|
|
of it will be returned by C<< $c->user >> when using |
72
|
|
|
|
|
|
|
L<Catalyst::Authentication::Store::Tangram>. Methods not defined in this module |
73
|
|
|
|
|
|
|
are passed through to the Tangram object. The object stringifies to the |
74
|
|
|
|
|
|
|
Tangram ID. |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=head1 METHODS |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=head2 new ($class, $storage, $tangram_object) |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
Simple constructor |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=head2 id |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
Unique Tangram ID for this object |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=head2 get_object |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
Returns the underlying Tangram user object. |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=head2 roles |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
Returns the list of roles which this user is authorised to do. |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=head2 supported_features |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
Returns hashref of features that this Authentication::User subclass supports. |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=head1 AUTHOR |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
Tomas Doran, <bobtfish at bobtfish dot net> |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
With thanks to state51, my employer, for giving me the time to work on this. |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=head1 BUGS |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
All complex software has bugs, and I'm sure that this module is no exception. |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
Please report bugs through the rt.cpan.org bug tracker. |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=head1 COPYRIGHT |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
Copyright (c) 2008, state51. Some rights reserved. |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
This module is free software; you can use, redistribute, and modify it under |
115
|
|
|
|
|
|
|
the same terms as Perl 5.8.x. |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=cut |
118
|
|
|
|
|
|
|
|