=head2 index log them in, and if next_page is present redirect them to that page Thanks plu! =cut sub index : Private { my ( $self, $c ) = @_; # Get the username and password from form my $username = $c->req->param('username'); my $password = $c->req->param('password'); $c->flash->{next_page} ||= $c->req->param('next_page'); # If the username and password values were found in form if ( $username && $password ) { # Attempt to log the user in if ( $c->login( $username, $password ) ) { my $redirect_url; if ( defined $c->flash->{next_page} ) { $redirect_url = $c->uri_for( $c->flash->{next_page} ) } else { $redirect_url = $c->uri_for( '/users/view', $username ); } # If successful, then let them use the application $c->res->redirect( $redirect_url ); } else { # Set an error message $c->stash->{error_msg} = "Bad username or password."; $c->stash->{template} = 'login.tt2'; return; } } # If either of above don't work out, send to the login page $c->stash->{template} = 'login.tt2'; } #### sub index : Private { my ( $self, $c ) = @_; # Get the username and password from form my $username = $c->req->param('username'); my $password = $c->req->param('password'); # If the username and password values were found in form if ( $username && $password ) { # Attempt to log the user in if ( $c->login( $username, $password ) ) { my $redirect_url = $c->req->param('next_page') ? $c->uri_for( $c->req->param('next_page') ) : $c->uri_for( '/users/view', $username ); $c->log->debug( "Redirect:" . $redirect_url ); # If successful, then let them use the application $c->res->redirect( $redirect_url ); } else { # Set an error message $c->stash->{error_msg} = "Bad username or password."; $c->stash->{template} = 'login.tt2'; return; } } # If either of above don't work out, send to the login page $c->stash->{template} = 'login.tt2'; } #### [info] OnTheBeach powered by Catalyst 5.7012 You can connect to your server at http://devin-desktop:3000 [info] *** Request 1 (0.001/s) [19945] [Mon Aug 4 22:02:12 2008] *** [debug] Query Parameters are: .-------------------------------------+--------------------------------------. | Parameter | Value | +-------------------------------------+--------------------------------------+ | next_page | /forum/create/1 | '-------------------------------------+--------------------------------------' [debug] "GET" request for "login" from "127.0.0.1" [debug] Path is "login" [debug] Rendering template "login.tt2" [debug] Found sessionid "95b2f79cba1750949c5bb6dbc44089a0dca767c7" in cookie [debug] Restored session "95b2f79cba1750949c5bb6dbc44089a0dca767c7" [debug] Applying HTML page layout wrappers to login.tt2 [info] Request took 0.150287s (6.654/s) .----------------------------------------------------------------+-----------. | Action | Time | +----------------------------------------------------------------+-----------+ | /auto | 0.000386s | | /login/index | 0.000297s | | /end | 0.127140s | | -> OnTheBeach::View::TT->process | 0.123267s | '----------------------------------------------------------------+-----------' [info] *** Request 7 (0.009/s) [19945] [Mon Aug 4 22:02:14 2008] *** [debug] Body Parameters are: .-------------------------------------+--------------------------------------. | Parameter | Value | +-------------------------------------+--------------------------------------+ | password | lairdo | | submit | Submit | | username | dhoss | '-------------------------------------+--------------------------------------' [debug] "POST" request for "login" from "127.0.0.1" [debug] Path is "login" [debug] Found sessionid "95b2f79cba1750949c5bb6dbc44089a0dca767c7" in cookie [debug] Restored session "95b2f79cba1750949c5bb6dbc44089a0dca767c7" [debug] Successfully authenticated user 'dhoss'. [debug] Redirect:http://localhost:3000/users/view/dhoss [debug] Redirecting to "http://localhost:3000/users/view/dhoss" [info] Request took 0.026401s (37.877/s) .----------------------------------------------------------------+-----------. | Action | Time | +----------------------------------------------------------------+-----------+ | /auto | 0.000275s | | /login/index | 0.007231s | | /end | 0.000975s | '----------------------------------------------------------------+-----------' [info] *** Request 8 (0.010/s) [19945] [Mon Aug 4 22:02:14 2008] *** [debug] "GET" request for "users/view/dhoss" from "127.0.0.1" [debug] Path is "users/view" [debug] Arguments are "dhoss" [debug] Rendering template "users/view.tt2" [debug] Found sessionid "95b2f79cba1750949c5bb6dbc44089a0dca767c7" in cookie [debug] Restored session "95b2f79cba1750949c5bb6dbc44089a0dca767c7" [debug] Applying HTML page layout wrappers to users/view.tt2 [info] Request took 0.039015s (25.631/s) .----------------------------------------------------------------+-----------. | Action | Time | +----------------------------------------------------------------+-----------+ | /auto | 0.000197s | | /users/view | 0.002659s | | /end | 0.020642s | | -> OnTheBeach::View::TT->process | 0.017903s | '----------------------------------------------------------------+-----------'