line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Mojolicious::Plugin::Tables::Controller::Auth; |
2
|
|
|
|
|
|
|
|
3
|
3
|
|
|
3
|
|
18866
|
use Mojo::Base 'Mojolicious::Controller'; |
|
3
|
|
|
|
|
8
|
|
|
3
|
|
|
|
|
27
|
|
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
|
14086
|
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
|
|
|
|
|
15
|
if (1) { |
20
|
6
|
|
|
|
|
46
|
$c->stash(user_id=>'administrator'); |
21
|
6
|
|
|
|
|
137
|
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; |