Implement under for session cookie

This commit is contained in:
swagg boi 2021-03-13 02:15:04 -05:00
parent 61a112a392
commit 051ff9a912

View file

@ -8,26 +8,23 @@ use Regexp::Common qw{net};
use Digest::SHA qw{sha1_hex};
use Number::Format qw{format_number};
## Let's set some things up first ##
plugin 'Config';
# CGI scripts
plugin CGI => ['/cgi-bin/guest' => './cgi-bin/guest_mm.cgi'];
plugin CGI => ['/cgi-bin/whoami' => './cgi-bin/whoami.cgi' ];
# Handle the GDPR non-compliance banner via session cookie
helper swaggSession => sub {
under sub {
my ($c) = @_;
if ($c->cookie('banner') eq 'seen') {
$c->session->{banner} = 'seen' unless $c->session->{banner}
}
return 1;
};
## Begin routes ##
# The main landing page; pass in the output of the fortune command
# The main landing page; index.html
get '/' => sub {
my ($c) = @_;
my $count = format_number time; # Grab epoch and add commas
@ -38,8 +35,6 @@ get '/' => sub {
fortune => $fortune
);
$c->swaggSession();
$c->render();
} => 'index';
@ -92,22 +87,17 @@ get '/ula6' => sub {
$ula6 = $uniqueid . ':/48';
}
$c->swaggSession();
$c->render(ula6 => $ula6);
};
# Catch any other route
# Default route
get '/:route' => [route => [qw{die me news}]] => sub {
my ($c) = @_;
my $route = $c->stash('route');
$c->swaggSession();
$c->render(template => $route);
};
## Send it ##
# Send it
app->secrets(app->config->{secrets}) || die $!;
app->start();