From 9a9a866b15968dabb2248d30551792e24da70464 Mon Sep 17 00:00:00 2001 From: Alex 'AdUser' Z Date: Sat, 16 Jun 2018 22:38:34 +1000 Subject: [PATCH] + LDV::Helpers->access_allowed --- lib/LDV/Helpers.pm | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lib/LDV/Helpers.pm b/lib/LDV/Helpers.pm index acf224b..80871bd 100644 --- a/lib/LDV/Helpers.pm +++ b/lib/LDV/Helpers.pm @@ -28,6 +28,16 @@ sub register { my ($c, $unixtime) = @_; return strftime("%Y-%m-%d %H:%M", localtime($unixtime)); }); + + $app->helper(access_allowed => sub { + my ($c, $level) = @_; + $level //= ''; + if ($level eq 'user' and not $c->session('useruid')) { + $c->redirect_to('/user/eaccess'); + return; + } + return 1; + }); } 1;