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 | |
7 | sub new { |
8 | my ( $class, $config, $app ) = @_; |
9 | |
10 | ## figure out if we are overriding the default store user class. |
11 | my $storeclass = $config->{'store_user_class'} || "Catalyst::Plugin::Authentication::Store::DBIx::Class::User"; |
12 | |
13 | ## fields can be specified to be ignored during user location. This allows |
14 | ## authinfo to contain the user info required to find the user, as well as the password |
15 | ## to try to match to, for example. It can be added to by setting ignore_fields in the |
16 | ## authinfo hashref also. |
17 | $config->{'ignore_fields_in_find'} ||= [ 'password' ]; |
18 | push @{$config->{'ignore_fields_in_find'}}, ('searchargs', 'ignore_fields'); |
19 | |
20 | ## make sure the store class is loaded. |
21 | Catalyst::Utils::ensure_class_loaded( $storeclass ); |
22 | |
23 | my $self = {}; |
24 | $self->{config} = $config; |
25 | $self->{store_user_class} = $storeclass; |
26 | |
27 | #$self->{role_relation} ||= 'roles'; |
28 | #$self->{role_field} ||= 'role'; |
29 | |
30 | bless $self, $class; |
31 | } |
32 | |
33 | sub from_session { |
34 | my ( $self, $c, $frozenuser ) = @_; |
35 | |
36 | return $frozenuser if ref $frozenuser; |
37 | |
38 | # this could be a lot better. But for now it just assumes $frozenuser is an id and uses find_user |
39 | # XXX: hits the database on every request? Not good... |
40 | return $self->find_user( { id => $frozenuser }, $c); |
41 | } |
42 | |
43 | sub for_session { |
44 | my ($self, $c, $user) = @_; |
45 | |
46 | return $user->for_session($c); |
47 | } |
48 | |
49 | sub find_user { |
50 | my ( $self, $authinfo, $c ) = @_; |
51 | |
52 | return $self->{'store_user_class'}->new($authinfo, $self->{config}, $c); |
53 | } |
54 | |
55 | |
56 | sub user_supports { |
57 | # this can work as a class method |
58 | shift->{'store_user_class'}->supports( @_ ); |
59 | } |
60 | |
61 | __PACKAGE__; |
62 | |
63 | __END__ |
64 | |
65 | =head1 NAME |
66 | |
67 | Catalyst::Plugin::Authentication::Store::DBIx::Class::Backend - A class to ... |
68 | |
69 | =head1 VERSION |
70 | |
71 | This documentation refers to version 0.01. |
72 | |
73 | =head1 SYNOPSIS |
74 | |
75 | use Catalyst::Plugin::Authentication::Store::DBIx::Class::Backend; |
76 | |
77 | =head1 DESCRIPTION |
78 | |
79 | The Catalyst::Plugin::Authentication::Store::DBIx::Class::Backend class implements ... |
80 | |
81 | =head1 SUBROUTINES / METHODS |
82 | |
83 | =head2 new (constructor) |
84 | |
85 | Parameters: |
86 | class |
87 | config |
88 | app |
89 | |
90 | Insert description of constructor here... |
91 | |
92 | =head2 from_session (method) |
93 | |
94 | Parameters: |
95 | c |
96 | frozenuser |
97 | |
98 | Insert description of method here... |
99 | |
100 | =head2 for_session (method) |
101 | |
102 | Parameters: |
103 | c |
104 | user |
105 | |
106 | Insert description of method here... |
107 | |
108 | =head2 find_user (method) |
109 | |
110 | Parameters: |
111 | authinfo |
112 | c |
113 | |
114 | Insert description of method here... |
115 | |
116 | =head2 user_supports |
117 | |
118 | Parameters: |
119 | none |
120 | |
121 | Insert description of subroutine here... |
122 | |
123 | =head1 DEPENDENCIES |
124 | |
125 | Modules used, version dependencies, core yes/no |
126 | |
127 | strict |
128 | |
129 | warnings |
130 | |
131 | =head1 NOTES |
132 | |
133 | ... |
134 | |
135 | =head1 BUGS AND LIMITATIONS |
136 | |
137 | None known currently, please email the author if you find any. |
138 | |
139 | =head1 SEE ALSO |
140 | |
141 | L<Catalyst::Plugin::Authentication::Store::DBIC>, L<Catalyst::Plugin::Authentication>, |
142 | L<Catalyst::Plugin::Authorization::Roles> |
143 | |
144 | =head1 AUTHOR |
145 | |
146 | Jason Kuri (jk@domain.tld) |
147 | |
148 | =head1 LICENCE |
149 | |
150 | Copyright 2006 by Jason Kuri. |
151 | |
152 | This software is free. It is licensed under the same terms as Perl itself. |
153 | |
154 | =cut |