cyberman/lib/cyberman/Helper.pm

28 lines
490 B
Perl
Raw Normal View History

2017-07-17 00:12:38 +02:00
package cyberman::Helper;
use base qw(Exporter);
use Dancer2 appname => "cyberman";
use Exporter qw(import);
our @EXPORT = qw(auth_test);
sub auth_test {
2017-07-17 01:35:13 +02:00
my $id = undef;
if (@_) {
$id = shift;
}
2017-07-17 00:12:38 +02:00
if (!vars->{"auth"}) {
return template 'redir' => {
"redir" => "/index",
};
2017-07-17 01:35:13 +02:00
} elsif ($id && vars->{"auth"} != $id) {
return template 'redir' => {
"redir" => "/index",
};
2017-07-17 00:12:38 +02:00
} else {
return 0; # nothing to be returned, route can continue
}
}
1;