line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Mojolicious::Plugin::Tables::Controller::Auth; |
2
|
|
|
|
|
|
|
|
3
|
3
|
|
|
3
|
|
18881
|
use Mojo::Base 'Mojolicious::Controller'; |
|
3
|
|
|
|
|
12
|
|
|
3
|
|
|
|
|
25
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
sub fail { |
6
|
0
|
|
|
0
|
0
|
0
|
my ($c,$error) = @_; |
7
|
0
|
|
0
|
|
|
0
|
$error ||= 'unspecified'; |
8
|
0
|
|
|
|
|
0
|
my $msg = "Table-level auth error was $error"; |
9
|
0
|
|
|
|
|
0
|
$c->app->log->error($msg); |
10
|
0
|
|
|
|
|
0
|
$c->render('exception', exception=>$msg, status=>401); |
11
|
0
|
|
|
|
|
0
|
return; |
12
|
|
|
|
|
|
|
} |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub ok { |
15
|
6
|
|
|
6
|
0
|
13808
|
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
|
|
|
|
|
20
|
if (1) { |
20
|
6
|
|
|
|
|
92
|
$c->stash(user_id=>'administrator'); |
21
|
6
|
|
|
|
|
142
|
return 1 |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
0
|
0
|
0
|
|
|
|
if (($c->stash('format')||'x') eq 'json') { |
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
|
|
|
|
|
|
|
1; |