]>
Dogcows Code - chaz/chatty/blob - lib/Chatty/Controller/Root.pm
1 package Chatty
::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 Chatty::Controller::Root - Root Controller for Chatty
19 Implements all actions for this simple chat application.
29 sub index :Path
:Args
(0) {
30 my ( $self, $c ) = @_;
35 Allow a user to login.
39 sub login
:Local
:Args
(0) {
41 if ($c->req->method eq 'POST' && exists($c->req->params->{handle
})) {
43 if ($c->authenticate({
44 username
=> $c->req->params->{handle
},
45 password
=> $c->req->params->{password
}
47 $c->change_session_id;
48 my $user = $c->user->get('username');
49 $c->flash->{message
} = "Hi, $user! You are now logged in.";
50 $c->response->redirect($c->uri_for('/'));
53 $c->flash->{error
} = "Log-in failed! Try again, I guess.";
54 $c->response->redirect($c->uri_for('login'));
66 sub logout
:Local
:Args
(0) {
68 if ($c->user_exists) {
70 $c->flash->{message
} = "Goodbye! You have been logged out.";
72 $c->response->redirect($c->uri_for('/'));
77 Register a new account.
81 sub register
:Local
:Args
(0) {
86 Standard 404 error page
92 $c->response->body('Page not found.');
93 $c->response->status(404);
98 Attempt to render a view, if needed.
102 sub end
: ActionClass
('RenderView') {}
110 This library is free software. You can redistribute it and/or modify
111 it under the same terms as Perl itself.
115 __PACKAGE__-
>meta->make_immutable;
This page took 0.042192 seconds and 4 git commands to generate.