| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
use strict; |
|
3
|
4
|
|
|
4
|
|
2297
|
use warnings; |
|
|
4
|
|
|
|
|
9
|
|
|
|
4
|
|
|
|
|
123
|
|
|
4
|
4
|
|
|
4
|
|
19
|
use parent 'Catalyst::Controller'; |
|
|
4
|
|
|
|
|
10
|
|
|
|
4
|
|
|
|
|
113
|
|
|
5
|
4
|
|
|
4
|
|
21
|
use Perl6::Junction qw/ any /; |
|
|
4
|
|
|
|
|
7
|
|
|
|
4
|
|
|
|
|
33
|
|
|
6
|
4
|
|
|
4
|
|
2178
|
use DateTime; |
|
|
4
|
|
|
|
|
24469
|
|
|
|
4
|
|
|
|
|
266
|
|
|
7
|
4
|
|
|
4
|
|
3109
|
|
|
|
4
|
|
|
|
|
1657096
|
|
|
|
4
|
|
|
|
|
1172
|
|
|
8
|
|
|
|
|
|
|
# |
|
9
|
|
|
|
|
|
|
# Sets the actions in this controller to be registered with no prefix |
|
10
|
|
|
|
|
|
|
# so they function identically to actions created in MyApp.pm |
|
11
|
|
|
|
|
|
|
# |
|
12
|
|
|
|
|
|
|
__PACKAGE__->config->{namespace} = ''; |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=head1 NAME |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
Bracket::Controller::Root - Root Controller for Bracket |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
Handle Security. |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
=head1 METHODS |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
=cut |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
=head2 auto |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
Make sure we're logged in when we should be. |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=cut |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
my ($self, $c) = @_; |
|
33
|
|
|
|
|
|
|
|
|
34
|
6
|
|
|
6
|
|
232530
|
my @open_actions = ( |
|
35
|
|
|
|
|
|
|
$c->controller('Auth')->action_for('register'), |
|
36
|
6
|
|
|
|
|
77
|
$c->controller('Auth')->action_for('login'), |
|
37
|
|
|
|
|
|
|
$c->controller('Auth')->action_for('email_reset_password_link'), |
|
38
|
|
|
|
|
|
|
$c->controller('Auth')->action_for('reset_password'), |
|
39
|
|
|
|
|
|
|
); |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
# Allow unauthenticated users to reach the open actions like 'login'. |
|
42
|
|
|
|
|
|
|
if ($c->action eq any(@open_actions)) { |
|
43
|
|
|
|
|
|
|
return 1; |
|
44
|
6
|
100
|
|
|
|
5379
|
} |
|
45
|
5
|
|
|
|
|
385
|
|
|
46
|
|
|
|
|
|
|
# If a user doesn't exist, force login |
|
47
|
|
|
|
|
|
|
if (!$c->user_exists) { |
|
48
|
|
|
|
|
|
|
|
|
49
|
1
|
50
|
|
|
|
116
|
# Redirect the user to the login page |
|
50
|
|
|
|
|
|
|
$c->response->redirect($c->uri_for($c->controller('Auth')->action_for('login'))); |
|
51
|
|
|
|
|
|
|
|
|
52
|
1
|
|
|
|
|
2024
|
# Return 0 to cancel 'post-auto' processing and prevent use of application |
|
53
|
|
|
|
|
|
|
return 0; |
|
54
|
|
|
|
|
|
|
} |
|
55
|
1
|
|
|
|
|
1493
|
else { |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
# Stash in home page link if we're not on home page. |
|
58
|
|
|
|
|
|
|
if ( |
|
59
|
|
|
|
|
|
|
($c->action ne $c->controller('Player')->action_for('home')) |
|
60
|
0
|
0
|
0
|
|
|
0
|
|| ( ($c->action eq $c->controller('Player')->action_for('home')) |
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
61
|
|
|
|
|
|
|
&& ($c->req->args->[0] && ($c->req->args->[0]) != $c->user->id)) |
|
62
|
|
|
|
|
|
|
) |
|
63
|
|
|
|
|
|
|
{ |
|
64
|
|
|
|
|
|
|
$c->stash->{show_home} = 1; |
|
65
|
|
|
|
|
|
|
} |
|
66
|
0
|
|
|
|
|
0
|
|
|
67
|
|
|
|
|
|
|
# See if player is an admin to get admin only links (e.g. Perfect Player access) |
|
68
|
|
|
|
|
|
|
my @user_roles = $c->user->roles; |
|
69
|
|
|
|
|
|
|
if ('admin' eq any(@user_roles)) { |
|
70
|
0
|
|
|
|
|
0
|
$c->stash->{is_admin} = 1; |
|
71
|
0
|
0
|
|
|
|
0
|
} |
|
72
|
0
|
|
|
|
|
0
|
|
|
73
|
|
|
|
|
|
|
# Set cutoff state |
|
74
|
|
|
|
|
|
|
my $cutoff_time = $self->edit_cutoff_time($c); |
|
75
|
|
|
|
|
|
|
$c->stash->{is_game_time} = (DateTime->now(time_zone => $cutoff_time->time_zone) > $cutoff_time); |
|
76
|
0
|
|
|
|
|
0
|
|
|
77
|
0
|
|
|
|
|
0
|
# Note if we have a normal user in game time (used to hide edit links) |
|
78
|
|
|
|
|
|
|
$c->stash->{is_normal_user_in_game_time} = |
|
79
|
|
|
|
|
|
|
(!$c->stash->{is_admin} && $c->stash->{is_game_time}); |
|
80
|
|
|
|
|
|
|
} |
|
81
|
0
|
|
0
|
|
|
0
|
|
|
82
|
|
|
|
|
|
|
# User found, so return 1 to continue with processing after this 'auto' |
|
83
|
|
|
|
|
|
|
return 1; |
|
84
|
|
|
|
|
|
|
|
|
85
|
0
|
|
|
|
|
0
|
} |
|
86
|
|
|
|
|
|
|
|
|
87
|
4
|
|
|
4
|
|
40
|
=head2 index |
|
|
4
|
|
|
|
|
9
|
|
|
|
4
|
|
|
|
|
39
|
|
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
Handle root index by redirecting to home when logged in. |
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=cut |
|
92
|
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
my ($self, $c) = @_; |
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
# Clear the user's state |
|
96
|
0
|
|
|
0
|
1
|
0
|
|
|
97
|
|
|
|
|
|
|
# Send the user to the starting point |
|
98
|
|
|
|
|
|
|
$c->go($c->controller('Player')->action_for('home'), [ $c->user->id ]); |
|
99
|
|
|
|
|
|
|
} |
|
100
|
|
|
|
|
|
|
|
|
101
|
0
|
|
|
|
|
0
|
=head2 default |
|
102
|
4
|
|
|
4
|
|
47514
|
|
|
|
4
|
|
|
|
|
10
|
|
|
|
4
|
|
|
|
|
19
|
|
|
103
|
|
|
|
|
|
|
=cut |
|
104
|
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
my ($self, $c) = @_; |
|
106
|
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
# $c->response->body( $c->welcome_message ); |
|
108
|
|
|
|
|
|
|
$c->go('/error_404'); |
|
109
|
0
|
|
|
0
|
1
|
0
|
|
|
110
|
|
|
|
|
|
|
} |
|
111
|
|
|
|
|
|
|
|
|
112
|
0
|
|
|
|
|
0
|
my ($self, $c) = @_; |
|
113
|
|
|
|
|
|
|
$c->res->status(404); |
|
114
|
4
|
|
|
4
|
|
3554
|
|
|
|
4
|
|
|
|
|
83
|
|
|
|
4
|
|
|
|
|
28
|
|
|
115
|
|
|
|
|
|
|
$c->stash->{template} = 'page_not_found.tt'; |
|
116
|
|
|
|
|
|
|
} |
|
117
|
0
|
|
|
0
|
0
|
0
|
|
|
118
|
0
|
|
|
|
|
0
|
=head2 end |
|
119
|
|
|
|
|
|
|
|
|
120
|
0
|
|
|
|
|
0
|
Attempt to render a view, if needed. |
|
121
|
4
|
|
|
4
|
|
3284
|
|
|
|
4
|
|
|
|
|
8
|
|
|
|
4
|
|
|
|
|
17
|
|
|
122
|
|
|
|
|
|
|
=cut |
|
123
|
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
} |
|
125
|
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
# This needs to be edited in future years to reflect the start date/time. |
|
127
|
|
|
|
|
|
|
# TODO: Put into conf |
|
128
|
|
|
|
|
|
|
my ($self, $c) = @_; |
|
129
|
|
|
|
6
|
1
|
|
|
|
130
|
4
|
|
|
4
|
|
3154
|
my $cutoff = $c->config->{edit_cutoff_time}; |
|
|
4
|
|
|
|
|
8
|
|
|
|
4
|
|
|
|
|
15
|
|
|
131
|
|
|
|
|
|
|
return DateTime->new( |
|
132
|
|
|
|
|
|
|
year => $cutoff->{year}, |
|
133
|
|
|
|
|
|
|
month => $cutoff->{month}, |
|
134
|
|
|
|
|
|
|
day => $cutoff->{day}, |
|
135
|
0
|
|
|
0
|
0
|
|
hour => $cutoff->{hour}, |
|
136
|
|
|
|
|
|
|
minute => $cutoff->{minute}, |
|
137
|
0
|
|
|
|
|
|
second => $cutoff->{second}, |
|
138
|
|
|
|
|
|
|
time_zone => $cutoff->{time_zone}, |
|
139
|
|
|
|
|
|
|
); |
|
140
|
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
} |
|
142
|
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
=head1 AUTHOR |
|
144
|
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
root |
|
146
|
0
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
=head1 LICENSE |
|
148
|
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
This library is free software, you can redistribute it and/or modify |
|
150
|
|
|
|
|
|
|
it under the same terms as Perl itself. |
|
151
|
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
=cut |
|
153
|
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
1; |