1 package Slists
::Controller
::Root
;
3 use namespace
::autoclean
;
5 BEGIN { extends
'Catalyst::Controller' }
8 # Sets the actions in this controller to be registered with no prefix
9 # so they function identically to actions created in MyApp.pm
11 __PACKAGE__
->config(namespace
=> '');
15 Slists::Controller::Root - Root Controller for Slists
19 [enter your description here]
25 Check if there is a user and, if not, forward to login page
29 # Note that 'auto' runs after 'begin' but before your actions and that
30 # 'auto's "chain" (all from application path to most specific class are run)
31 # See the 'Actions' section of 'Catalyst::Manual::Intro' for more info.
35 # Allow unauthenticated users to reach the login page. This
36 # allows unauthenticated users to reach any action in the Login
37 # controller. To lock it down to a single action, we could use:
38 # if ($c->action eq $c->controller('Login')->action_for('index'))
39 # to only allow unauthenticated access to the 'index' action we
41 if ($c->controller eq $c->controller('Login')) {
45 # If a user doesn't exist, force login
46 if (!$c->user_exists) {
47 # Dump a log message to the development server debug output
48 $c->log->debug('***Root::auto User not found, forwarding to /login');
49 # Redirect the user to the login page
50 $c->response->redirect($c->uri_for('/login'));
51 # Return 0 to cancel 'post-auto' processing and prevent use of application
55 # User found, so return 1 to continue with processing after this 'auto'
66 sub index :Path
:Args
(0) {
67 my ( $self, $c ) = @_;
70 $c->response->body( $c->welcome_message );
75 Standard 404 error page
80 my ( $self, $c ) = @_;
81 $c->response->body( 'Page not found' );
82 $c->response->status(404);
87 Attempt to render a view, if needed.
91 sub end
: ActionClass
('RenderView') {}
99 This library is free software. You can redistribute it and/or modify
100 it under the same terms as Perl itself.
104 __PACKAGE__
->meta->make_immutable;