| 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"
MC/DC0%0/1
$error ||= "unspecified"
$error
Truth table0%0/2
A
A= $error
| |||||||||||||||||||||
| 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
Condition0%0/2
$c->stash('format') || 'x'
MC/DC0%0/1
$c->stash('format') || 'x'
$c->stash('format')
Truth table0%0/2
A
A= $c->stash('format')
| |||||||||||||||||||||
| 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; | |||||||||||||||||||