Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- CREATE TABLE people (
- id integer primary key,
- name text not null,
- password text not null);
- __PACKAGE__->config('Plugin::Authentication' => {
- default => { credential => {
- class => 'Password',
- password_field => 'password',
- password_type => 'clear'
- },
- store => {
- class => 'DBIx::Class',
- user_model => 'People'
- }
- }
- }
- );
- sub login : Local {
- my ($self, $c) = @_;
- if (my $user = $c->req->params->{user} and my $password = $c->req->params->{password} ) {
- if ( $c->authenticate( { username => $user, password => $password } ) ) {
- $c->res->body( "hello " . $c->user->get("id") );
- } else {
- # login incorrect
- $c->res->body("Wrong pass or name!");
- }
- } else {
- # invalid form input
- $c->res->body("Type name & pass");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement