File Coverage

blib/lib/CatalystX/SimpleLogin.pm
Criterion Covered Total %
statement 9 9 100.0
branch n/a
condition n/a
subroutine 3 3 100.0
pod n/a
total 12 12 100.0


line stmt bran cond sub pod time code
1             package CatalystX::SimpleLogin;
2 9     9   11286174 use Moose::Role;
  9         367727  
  9         72  
3 9     9   35016 use CatalystX::InjectComponent;
  9         5371  
  9         185  
4 9     9   37 use namespace::autoclean;
  9         16  
  9         67  
5              
6             our $VERSION = '0.19';
7              
8             after 'setup_components' => sub {
9             my $class = shift;
10             CatalystX::InjectComponent->inject(
11             into => $class,
12             component => 'CatalystX::SimpleLogin::Controller::Login',
13             as => 'Controller::Login'
14             );
15             };
16              
17             =head1 NAME
18              
19             CatalystX::SimpleLogin - Provide a simple Login controller which can be reused
20              
21             =head1 SYNOPSIS
22              
23             package MyApp;
24             use Moose;
25             use namespace::autoclean;
26              
27             use Catalyst qw/
28             +CatalystX::SimpleLogin
29             Authentication
30             Session
31             Session::State::Cookie
32             Session::Store::File
33             /;
34             extends 'Catalyst';
35              
36             __PACKAGE__->config(
37             'Plugin::Authentication' => { # Auth config here }
38             );
39              
40             __PACKAGE__->config(
41             'Controller::Login' => { # SimpleLogin config here }
42             );
43              
44             __PACKAGE__->setup;
45              
46             =head1 ATTENTION!
47              
48             If you're new here, you should start by reading
49             L<CatalystX::SimpleLogin::Manual>, which provides a gentler introduction to
50             using this code. Come back here when you're done there.
51              
52             =head1 DESCRIPTION
53              
54             CatalystX::SimpleLogin is an application class L<Moose::Role> which will
55             inject a L<Catalyst::Controller>
56             which is an instance of L<CatalystX::SimpleLogin::Controller::Login> into your
57             application. This provides a simple login and logout page with the addition
58             of only one line of code and one template to your application.
59              
60             =head1 REQUIREMENTS
61              
62             =over
63              
64             =item A Catalyst application
65              
66             =item Working authentication configuration
67              
68             =item Working session configuration
69              
70             =item A view
71              
72             =back
73              
74             =head1 CUSTOMISATION
75              
76             CatalystX::SimpleLogin is a prototype for CatalystX::Elements. As such, one of the goals
77             is to make it easy for users to customise the provided component to the maximum degree
78             possible, and also, to have a linear relationship between effort invested and level of
79             customisation achieved.
80              
81             Three traits are shipped with SimpleLogin: WithRedirect, Logout, and RenderAsTTTemplate.
82             These traits are set in the config:
83              
84             __PACKAGE__->config(
85             'Controller::Login' => {
86             traits => [qw/ Logout WithRedirect RenderAsTTTemplate /],
87             login_form_args => { # see the login form },
88             );
89              
90             =head1 COMPONENTS
91              
92             =over
93              
94             =item *
95              
96             L<CatalystX::SimpleLogin::Controller::Login> - first point of call for customisation.
97             Override the action configs to reconfigure the paths of the login or logout actions.
98             Subclass to be able to apply method modifiers to run before / after the login or
99             logout actions or override methods.
100              
101             =item *
102              
103             L<CatalystX::SimpleLogin::TraitFor::Controller::Login::Logout> - provides the C<logout> action
104             and associated methods. You can compose this manually yourself if you want just that
105             action.
106              
107             This trait is set by default, but if you set another trait in your config, you
108             will have to include it.
109              
110             =item *
111              
112             L<CatalystX::SimpleLogin::TraitFor::Controller::Login::WithRedirect> - provides the C<login>
113             action with a wrapper to redirect to a page which needs authentication, from which the
114             user was previously redirected. Goes hand in hand with L<Catalyst::ActionRole::NeedsLogin>
115              
116             =item *
117              
118             L<CatalystX::SimpleLogin::TraitFor::Controller::Login::RenderAsTTTemplate> - sets
119             the stash variable 'template' to point to a string reference containing the
120             rendered template so that it's not necessary to have a login.tt template file.
121              
122             =item *
123              
124             L<CatalystX::SimpleLogin::Form::Login> - the L<HTML::FormHandler> form for the login form.
125              
126             =item *
127              
128             L<Catalyst::ActionRole::NeedsLogin> - Used to cause a specific path to redirect to the login
129             page if a user is not authenticated.
130              
131             =back
132              
133             =head1 TODO
134              
135             Here's a list of what I think needs working on, in no particular order.
136              
137             Please feel free to add to or re-arrange this list :)
138              
139             =over
140              
141             =item Fix extension documentation
142              
143             =item Document all this stuff.
144              
145             =item Examples of use / customisation in documentation
146              
147             =item Fixing one uninitialized value warning in LoginRedirect
148              
149             =item Disable the use of NeedsLogin ActionRole when WithRedirect is not loaded
150              
151             =back
152              
153             =head1 SOURCE CODE
154              
155             http://github.com/bobtfish/catalystx-simplelogin/tree/master
156              
157             git://github.com/bobtfish/catalystx-simplelogin.git
158              
159             Forks and patches are welcome. #formhandler or #catalyst (irc.perl.org)
160             are both good places to ask about using or developing this code.
161              
162             =head1 SEE ALSO
163              
164             =over
165              
166             =item *
167              
168             L<Catalyst>
169              
170             =item *
171              
172             L<Moose> and L<Moose::Role>
173              
174             =item *
175              
176             L<MooseX::MethodAttributes::Role> - Actions composed from L<Moose::Role>.
177              
178             =item *
179              
180             L<CatalystX::InjectComponent> - Injects the controller class
181              
182             =item *
183              
184             L<HTML::FormHandler> - Generates the login form
185              
186             =item *
187              
188             L<Catalyst::Plugin::Authentication> - Responsible for the actual heavy lifting of authenticating the user
189              
190             =item *
191              
192             L<Catalyst::Plugin::Session>
193              
194             =item *
195              
196             L<Catalyst::Controller> - Allows you to decorate actions with roles (E.g L<Catalyst::ActionRole::NeedsLogin|To force a redirect to the login page>)
197              
198             =item *
199              
200             L<CatalystX::Component::Traits> - Allows L<Moose::Role|roles> to be composed onto components from config
201              
202             =back
203              
204             =head1 AUTHORS
205              
206             =over
207              
208             =item Tomas Doran (t0m) C<< bobtfish@bobtfish.net >>
209              
210             =item Zbigniew Lukasiak
211              
212             =item Stephan Jauernick (stephan48) C<< stephan@stejau.de >>
213              
214             =item Gerda Shank (gshank) C<< gshank@cpan.org >>
215              
216             =item Florian Ragwitz C<< rafl@debian.org >>
217              
218             =item Shlomi Fish
219              
220             =item Oleg Kostyuk (cub-uanic) C<< cub@cpan.org >>
221              
222             =back
223              
224             =head1 LICENSE
225              
226             Copyright 2009 Tomas Doran. Some rights reserved.
227              
228             This software is free software, and is licensed under the same terms as perl itself.
229              
230             =cut
231              
232             1;
233