Advertisement
Guest User

Untitled

a guest
Jan 13th, 2016
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.95 KB | None | 0 0
  1. # Get the username and password from form
  2. my $username = $c->request->params->{username};
  3. my $password = $c->request->params->{password};
  4.  
  5. # If the username and password values were found in form
  6. if ($username && $password) {
  7. # Attempt to log the user in
  8. if ($c->authenticate({ username => $username,
  9. password => $password } )) {
  10. # If successful, then let them use the application
  11. $c->response->redirect($c->uri_for(
  12. $c->controller('Books')->action_for('list')));
  13. return;
  14. } else {
  15. # Set an error message
  16. $c->stash(error_msg => "Bad username or password.");
  17. }
  18. } else {
  19. # Set an error message
  20. $c->stash(error_msg => "Empty username or password.")
  21. unless ($c->user_exists);
  22. }
  23.  
  24. # If either of above don't work out, send to the login page
  25. $c->stash(template => 'login.tt2');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement