Wishlist/Controller/Access.pm

filter: Statementstmt 16.6% 4 / 24 Branchbran 0.0% 0 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 25.0% 1 / 4 Podpod 0.0% 0 / 3 totaltotal 13.5% 5 / 37 CC 4 SCAR 19.9
CC
4
Cov
13%
register
12.0
login
6.0
logout
2.0
CRAP 7.3
« Wishlist.pm ↑ Summary Wishlist/Controller/List.pm »
1 package Wishlist::Controller::Access;
2 2 ▶use Mojo::Base 'Mojolicious::Controller';
Subroutine BEGIN: called CC=1 SCAR=0.0
3  
4 0 ▶sub login {
Subroutine login: not called CC=2 SCAR=17.9
Pod undocumented
5 0 my $c = shift;
6 0 my $username = $c->param('username');
7 0 my $password = $c->param('password');
8 0 ▶ if ($c->model->check_password($username, $password)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($c->model->check_password($username, $password)) 0 0 0
9 0 $c->session->{username} = $username;
10 }
11 0 $c->redirect_to('/');
12 }
13  
14 0 ▶sub register {
Subroutine register: not called CC=3 SCAR=24.8
Pod undocumented
15 0 my $c = shift;
16 0 my $username = $c->param('username');
17 0 my $user = {
18 username => $username,
19 password => $c->param('password'),
20 name => $c->param('name'),
21 };
22 0 warn Mojo::Util::dumper $user;
23 0 ▶ unless(eval { $c->model->add_user($user); 1 }) {
Branch: 1 branch
BranchTrueFalseTotal
unless (eval { do { $c->model->add_user($user); 1 } }) 0 0 0
24 0 ▶ $c->app->log->error($@) if $@;
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 0 0
25 0 return $c->render(text => 'Could not create user', status => 400);
26 }
27 0 $c->session->{username} = $username;
28 0 $c->redirect_to('/');
29 };
30  
31 0 ▶sub logout {
Subroutine logout: not called CC=1 SCAR=6.9
Pod undocumented
32 0 my $c = shift;
33 0 $c->session(expires => 1);
34 0 $c->redirect_to('/');
35 }
36  
37 2 1;
38  
« Wishlist.pm ↑ Summary Wishlist/Controller/List.pm »