Advertisement
Guest User

Untitled

a guest
Feb 2nd, 2016
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.97 KB | None | 0 0
  1. CREATE TABLE people (
  2. id integer primary key,
  3. name text not null,
  4. password text not null);
  5.  
  6. __PACKAGE__->config('Plugin::Authentication' => {
  7. default => { credential => {
  8. class => 'Password',
  9. password_field => 'password',
  10. password_type => 'clear'
  11. },
  12. store => {
  13. class => 'DBIx::Class',
  14. user_model => 'People'
  15. }
  16. }
  17. }
  18. );
  19.  
  20. sub login : Local {
  21. my ($self, $c) = @_;
  22.  
  23. if (my $user = $c->req->params->{user} and my $password = $c->req->params->{password} ) {
  24. if ( $c->authenticate( { username => $user, password => $password } ) ) {
  25. $c->res->body( "hello " . $c->user->get("id") );
  26. } else {
  27. # login incorrect
  28. $c->res->body("Wrong pass or name!");
  29. }
  30. } else {
  31. # invalid form input
  32. $c->res->body("Type name & pass");
  33. }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement