Created
January 3, 2011 20:09
-
-
Save zipkid/763885 to your computer and use it in GitHub Desktop.
Mojolicious test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
calling /customers (a protected path) | |
-> login | |
-> Use of uninitialized value in warn at script/../lib/Ds/Controllers/Auth.pm line 18. | |
(line 18 is the warn in the sub index) | |
#routes | |
$r->route('/')->to('index#welcome' )->name('index'); | |
$r->route('/login')->to('auth#index' )->name('login'); | |
$r->route('/logout')->to('auth#logout' )->name('logout'); | |
my $auth = $r->bridge->to('Auth#protected'); | |
package Ds::Controllers::Auth; | |
use strict; | |
use warnings; | |
use base 'Mojolicious::Controller'; | |
my $USERS = { | |
zipkid => 'secr3t', | |
}; | |
sub index { | |
my $c = shift; | |
my $user = $c->param('user') || ''; | |
my $pass = $c->param('pass') || ''; | |
return $c->render unless $USERS->{$user} && $USERS->{$user} eq $pass; | |
$c->session( user => $user ); | |
warn $c->flash->{'redirect_path'}; | |
# redirect to requested path here. | |
$c->redirect_to( 'index' ); | |
} | |
sub protected { | |
my $c = shift; | |
return 1 if defined $c->session('user'); | |
$c->flash( redirect_path => $c->req->url->path ); | |
return $c->redirect_to( 'login' ); | |
} | |
1; | |
log | |
Mon Jan 3 21:19:05 2011 debug Mojolicious::Plugin::RequestTimer:32 [6754]: GET //customers (Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv:1.9.2.13) Gecko/20101203 Firefox/3.6.13). | |
Mon Jan 3 21:19:05 2011 debug Mojolicious::Routes:421 [6754]: Dispatching Ds::Controllers::Auth->protected. | |
Mon Jan 3 21:19:05 2011 debug Ds::Controllers::Auth:38 [6754]: = = =Ds::Auth::protected | |
Mon Jan 3 21:19:05 2011 debug Ds::Controllers::Auth:42 [6754]: user not defined | |
/customers at script/../lib/Ds/Controllers/Auth.pm line 44. | |
Mon Jan 3 21:19:05 2011 debug Mojolicious::Plugin::RequestTimer:57 [6754]: 302 Found (0.004240s, 235.849/s). | |
Mon Jan 3 21:19:05 2011 debug Mojolicious::Routes:421 [6754]: Dispatching Ds::Controllers::Customers->index. | |
Mon Jan 3 21:19:05 2011 debug Mojolicious::Plugin::RequestTimer:32 [6754]: GET //login (Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv:1.9.2.13) Gecko/20101203 Firefox/3.6.13). | |
Mon Jan 3 21:19:05 2011 debug Mojolicious::Routes:421 [6754]: Dispatching Ds::Controllers::Auth->index. | |
Mon Jan 3 21:19:05 2011 debug Ds::Controllers::Auth:16 [6754]: = = Ds::Auth::index Not logged in | |
Use of uninitialized value in warn at script/../lib/Ds/Controllers/Auth.pm line 18. | |
Warning: something's wrong at script/../lib/Ds/Controllers/Auth.pm line 18. | |
/customers at script/../lib/Ds/Controllers/Auth.pm line 19. | |
Mon Jan 3 21:19:05 2011 debug Mojolicious::Plugin::RequestTimer:57 [6754]: 200 OK (0.017065s, 58.599/s). |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment