Tables/Controller/Auth.pm

filter: Statementstmt 40.0% 8 / 20 Branchbran 0.0% 0 / 2 Conditioncond 0.0% 0 / 4 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 66.6% 2 / 3 Podpod 0.0% 0 / 2 totaltotal 30.3% 10 / 33 CC 4 SCAR 16.7
CC
4
Cov
31%
ok
6.3
fail
6.0
BEGIN
1.0
CRAP 5.3
« Tables/Model/Row.pm ↑ Summary
1 package Mojolicious::Plugin::Tables::Controller::Auth;
2  
3 3 ▶use Mojo::Base 'Mojolicious::Controller';
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 0 ▶sub fail {
Subroutine fail: not called CC=2 SCAR=17.9
Pod undocumented
6 0 my ($c,$error) = @_;
7 0 ▶ $error ||= 'unspecified';
Condition0%0/2
$error ||= "unspecified"
l!l
00
MC/DC0%0/1
$error ||= "unspecified"
$error
Truth table0%0/2
A
A= $error
Aresult
11
00
8 0 my $msg = "Table-level auth error was $error";
9 0 $c->app->log->error($msg);
10 0 $c->render('exception', exception=>$msg, status=>401);
11 0 return;
12 }
13  
14 6 ▶sub ok {
Subroutine ok: called CC=3 SCAR=18.4
Pod undocumented
15 6 my $c = shift;
16  
17 # apply site-wide session, cookie, or request-based authorisation here..
18 # and set authorised username into the session.
19 6 if (1) {
20 6 $c->stash(user_id=>'administrator');
21 6 return 1
22 }
23  
24 0 ▶ if (($c->stash('format')||'x') eq 'json') {
Branch: 1 branch
BranchTrueFalseTotal
if (($c->stash("format") || "x") eq "json") 0 0 0
Condition0%0/2
$c->stash('format') || 'x'
l!l
00
MC/DC0%0/1
$c->stash('format') || 'x'
$c->stash('format')
Truth table0%0/2
A
A= $c->stash('format')
Aresult
11
00
25 0 $c->fail;
26 0 return;
27 }
28  
29 0 $c->add_flash(errors => 'Please sign in first using your Google ID.');
30 0 $c->redirect_to('/');
31 0 return;
32 }
33  
34 3 1;
« Tables/Model/Row.pm ↑ Summary