Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Get the username and password from form
- my $username = $c->request->params->{username};
- my $password = $c->request->params->{password};
- # If the username and password values were found in form
- if ($username && $password) {
- # Attempt to log the user in
- if ($c->authenticate({ username => $username,
- password => $password } )) {
- # If successful, then let them use the application
- $c->response->redirect($c->uri_for(
- $c->controller('Books')->action_for('list')));
- return;
- } else {
- # Set an error message
- $c->stash(error_msg => "Bad username or password.");
- }
- } else {
- # Set an error message
- $c->stash(error_msg => "Empty username or password.")
- unless ($c->user_exists);
- }
- # If either of above don't work out, send to the login page
- $c->stash(template => 'login.tt2');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement