line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Mojolicious::Plugin::Tables::Controller::Auth; |
2
|
|
|
|
|
|
|
|
3
|
3
|
|
|
3
|
|
20040
|
use Mojo::Base 'Mojolicious::Controller'; |
|
3
|
|
|
|
|
10
|
|
|
3
|
|
|
|
|
28
|
|
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
|
15023
|
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
|
|
|
|
|
17
|
if (1) { |
20
|
6
|
|
|
|
|
44
|
$c->stash(user_id=>'administrator'); |
21
|
6
|
|
|
|
|
139
|
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; |