blib/lib/Galileo/User.pm untested

filter: Statementstmt 0.0% 0 / 20 Branchbran 0.0% 0 / 2 Conditioncond 0.0% 0 / 3 MC/DCmcdc n/a Subroutinesub 0.0% 0 / 3 Podpod 0.0% 0 / 2 totaltotal 0.0% 0 / 30 CC 2 SCAR 13.9
CC
2
Cov
0%
login
6.0
logout
2.0
BEGIN
2.0
CRAP 4.0
1 package Galileo::User;
2 use Mojo::Base 'Mojolicious::Controller';
3  
4 sub login {
5 my $self = shift;
6 my $name = $self->param('username');
7 my $pass = $self->param('password');
8 my $from = $self->param('from');
9  
10 my $schema = $self->schema;
11  
12 my $user = $schema->resultset('User')->single({name => $name});
13 if ($user and $user->check_password($pass)) {
14 $self->humane_flash( 'Welcome Back!' );
15 $self->session->{id} = $user->user_id;
16 $self->session->{username} = $name;
17 } else {
18 $self->humane_flash( 'Sorry try again' );
19 }
20 $self->redirect_to( $from );
21 }
22  
23 sub logout {
24 my $self = shift;
25 $self->session( expires => 1 );
26 $self->humane_flash( 'Goodbye' );
27 $self->redirect_to( $self->home_page );
28 }
29  
30 1;
31