forked from .cyb/cyberman
More rigorous auth-checking
This commit is contained in:
parent
ec72bd2a1e
commit
13447382a2
|
@ -3,10 +3,10 @@ package cyberman::Domains;
|
||||||
use Dancer2 appname => "cyberman";
|
use Dancer2 appname => "cyberman";
|
||||||
use Dancer2::Plugin::Database;
|
use Dancer2::Plugin::Database;
|
||||||
|
|
||||||
|
use cyberman::Helper qw(auth_test);
|
||||||
|
|
||||||
get '/domains' => sub {
|
get '/domains' => sub {
|
||||||
return template 'redir' => {
|
return auth_test() if auth_test();
|
||||||
"redir" => "index",
|
|
||||||
} unless vars->{"auth"};
|
|
||||||
|
|
||||||
my @domains = database->quick_select(
|
my @domains = database->quick_select(
|
||||||
"domain",
|
"domain",
|
||||||
|
@ -21,6 +21,8 @@ get '/domains' => sub {
|
||||||
};
|
};
|
||||||
|
|
||||||
post '/domains/new' => sub {
|
post '/domains/new' => sub {
|
||||||
|
return auth_test() if auth_test();
|
||||||
|
|
||||||
my %errs;
|
my %errs;
|
||||||
|
|
||||||
if (!param("name")) {
|
if (!param("name")) {
|
||||||
|
|
|
@ -0,0 +1,18 @@
|
||||||
|
package cyberman::Helper;
|
||||||
|
use base qw(Exporter);
|
||||||
|
use Dancer2 appname => "cyberman";
|
||||||
|
use Exporter qw(import);
|
||||||
|
|
||||||
|
our @EXPORT = qw(auth_test);
|
||||||
|
|
||||||
|
sub auth_test {
|
||||||
|
if (!vars->{"auth"}) {
|
||||||
|
return template 'redir' => {
|
||||||
|
"redir" => "/index",
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
return 0; # nothing to be returned, route can continue
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
1;
|
Loading…
Reference in New Issue