Commit | Line | Data |
5000f545 |
1 | package Catalyst::Plugin::Authentication::Store::DBIx::Class::Backend; |
2 | |
3 | use strict; |
4 | use warnings; |
5 | use base qw/Class::Accessor::Fast/; |
6 | |
b33ee900 |
7 | our $VERSION= "0.02"; |
8 | |
9 | BEGIN { |
10 | __PACKAGE__->mk_accessors(qw/config/); |
11 | } |
12 | |
13 | |
5000f545 |
14 | sub new { |
15 | my ( $class, $config, $app ) = @_; |
16 | |
b33ee900 |
17 | ## figure out if we are overriding the default store user class |
18 | $config->{'store_user_class'} = (exists($config->{'store_user_class'})) ? $config->{'store_user_class'} : |
19 | "Catalyst::Plugin::Authentication::Store::DBIx::Class::User"; |
20 | |
5000f545 |
21 | ## make sure the store class is loaded. |
b33ee900 |
22 | Catalyst::Utils::ensure_class_loaded( $config->{'store_user_class'} ); |
5000f545 |
23 | |
b33ee900 |
24 | ## fields can be specified to be ignored during user location. This allows |
25 | ## the backend to ignore certain fields in the authinfo hash. |
5000f545 |
26 | |
b33ee900 |
27 | $config->{'ignore_fields_in_find'} ||= [ ]; |
28 | |
29 | my $self = { |
30 | config => $config |
31 | }; |
5000f545 |
32 | |
33 | bless $self, $class; |
b33ee900 |
34 | |
5000f545 |
35 | } |
36 | |
ba48c9c3 |
37 | ## --jk note to self: |
38 | ## let's use DBICs get_columns method to return a hash and save / restore that |
39 | ## from the session. Then we can respond to get() calls, etc. in most cases without |
40 | ## resorting to a DB call. If user_object is called, THEN we can hit the DB and |
41 | ## return a real object. |
5000f545 |
42 | sub from_session { |
43 | my ( $self, $c, $frozenuser ) = @_; |
44 | |
45 | return $frozenuser if ref $frozenuser; |
b33ee900 |
46 | |
47 | my $user = $self->config->{'store_user_class'}->new($self->{'config'}, $c); |
48 | |
49 | return $user->from_session($frozenuser, $c); |
5000f545 |
50 | } |
51 | |
52 | sub for_session { |
53 | my ($self, $c, $user) = @_; |
54 | |
55 | return $user->for_session($c); |
56 | } |
57 | |
58 | sub find_user { |
59 | my ( $self, $authinfo, $c ) = @_; |
60 | |
b33ee900 |
61 | my $user = $self->config->{'store_user_class'}->new($self->{'config'}, $c); |
5000f545 |
62 | |
b33ee900 |
63 | return $user->load($authinfo, $c); |
64 | |
65 | } |
5000f545 |
66 | |
67 | sub user_supports { |
b33ee900 |
68 | my $self = shift; |
69 | # this can work as a class method on the user class |
70 | $self->config->{'store_user_class'}->supports( @_ ); |
5000f545 |
71 | } |
72 | |
73 | __PACKAGE__; |
74 | |
75 | __END__ |
76 | |
77 | =head1 NAME |
78 | |
79 | Catalyst::Plugin::Authentication::Store::DBIx::Class::Backend - A class to ... |
80 | |
81 | =head1 VERSION |
82 | |
83 | This documentation refers to version 0.01. |
84 | |
85 | =head1 SYNOPSIS |
86 | |
87 | use Catalyst::Plugin::Authentication::Store::DBIx::Class::Backend; |
88 | |
89 | =head1 DESCRIPTION |
90 | |
91 | The Catalyst::Plugin::Authentication::Store::DBIx::Class::Backend class implements ... |
92 | |
93 | =head1 SUBROUTINES / METHODS |
94 | |
95 | =head2 new (constructor) |
96 | |
97 | Parameters: |
98 | class |
99 | config |
100 | app |
101 | |
102 | Insert description of constructor here... |
103 | |
104 | =head2 from_session (method) |
105 | |
106 | Parameters: |
107 | c |
108 | frozenuser |
109 | |
110 | Insert description of method here... |
111 | |
112 | =head2 for_session (method) |
113 | |
114 | Parameters: |
115 | c |
116 | user |
117 | |
118 | Insert description of method here... |
119 | |
120 | =head2 find_user (method) |
121 | |
122 | Parameters: |
123 | authinfo |
124 | c |
125 | |
126 | Insert description of method here... |
127 | |
128 | =head2 user_supports |
129 | |
130 | Parameters: |
131 | none |
132 | |
133 | Insert description of subroutine here... |
134 | |
135 | =head1 DEPENDENCIES |
136 | |
137 | Modules used, version dependencies, core yes/no |
138 | |
139 | strict |
140 | |
141 | warnings |
142 | |
143 | =head1 NOTES |
144 | |
145 | ... |
146 | |
147 | =head1 BUGS AND LIMITATIONS |
148 | |
149 | None known currently, please email the author if you find any. |
150 | |
151 | =head1 SEE ALSO |
152 | |
153 | L<Catalyst::Plugin::Authentication::Store::DBIC>, L<Catalyst::Plugin::Authentication>, |
154 | L<Catalyst::Plugin::Authorization::Roles> |
155 | |
156 | =head1 AUTHOR |
157 | |
b33ee900 |
158 | Jason Kuri (jayk@cpan.org) |
5000f545 |
159 | |
160 | =head1 LICENCE |
161 | |
162 | Copyright 2006 by Jason Kuri. |
163 | |
164 | This software is free. It is licensed under the same terms as Perl itself. |
165 | |
166 | =cut |