File Coverage

blib/lib/AproJo/User.pm
Criterion Covered Total %
statement 20 20 100.0
branch 2 2 100.0
condition 3 3 100.0
subroutine 4 4 100.0
pod 0 2 0.0
total 29 31 93.5


line stmt bran cond sub pod time code
1             package AproJo::User;
2 2     2   134879 use Mojo::Base 'Mojolicious::Controller';
  2         3  
  2         8  
3              
4 2     2   251 use Data::Dumper;
  2         3  
  2         348  
5              
6             sub login {
7 3     3 0 45876 my $self = shift;
8 3         13 my $name = $self->param('username');
9 3         842 my $pass = $self->param('password');
10 3         121 my $from = $self->param('from');
11              
12 3         114 my $schema = $self->schema;
13              
14 3         42 my $user = $schema->resultset('User')->single({name => $name});
15              
16 3 100 100     5860 if ($user and $user->password eq $pass) {
17              
18 1         89 $self->session->{id} = $user->user_id;
19 1         303 $self->session->{username} = $name;
20              
21             }
22             else {
23 2         107 $self->flash(onload_message => "Sorry try again");
24             }
25              
26             #$self->redirect_to( $from );
27 3         419 $self->redirect_to("/");
28             }
29              
30             sub logout {
31 1     1 0 65585 my $self = shift;
32 1         6 $self->session(expires => 1);
33 1         381 $self->redirect_to($self->home_page);
34             }
35              
36             1;
37