Use perlcritic theme; add is_admin() helper; clean up some things

This commit is contained in:
swagg boi 2022-12-18 14:00:54 -05:00
parent 4527219d91
commit 5cce06c984
4 changed files with 24 additions and 4 deletions

View file

@ -1 +1 @@
exclude = Subroutines::ProhibitSubroutinePrototypes
theme = community

View file

@ -4,3 +4,4 @@ requires 'Mojolicious::Plugin::TagHelpers::Pagination';
requires 'Mojolicious::Plugin::AssetPack';
requires 'Crypt::Passphrase::Argon2';
requires 'Crypt::Passphrase::Bcrypt'; # Needed for old passphrases
requires 'Perl::Critic::Community';

View file

@ -58,6 +58,14 @@ sub startup($self) {
return undef;
});
$self->helper(is_admin => sub ($c) {
if (my $admin_id = $c->session->{'admin_id'}) {
return 1 if $admin_id =~ /\d+/
}
return undef;
});
# Finish configuring some things
$self->secrets($self->config->{'secrets'}) || die $@;
@ -144,7 +152,7 @@ sub startup($self) {
my $moderator = $r->under('/moderator', sub ($c) {
return 1 if $c->is_mod;
# Return false otherwise a body is rendered with the redirect...
# Return undef otherwise a body is rendered with the redirect...
return $c->redirect_to('mod_login'), undef;
});
@ -183,6 +191,15 @@ sub startup($self) {
$mod_remark->get('/unhide/:remark_id', [remark_id => qr/\d+/])
->to('moderator#unhide_remark')
->name('unhide_remark');
my $admin = $moderator->under('/admin', sub ($c) {
return 1 if $c->is_admin;
# Return undef otherwise a body is rendered with the redirect...
return $c->recirect_to('mod_login'), undef;
});
# Actions to create mods...
}
1;

View file

@ -1,2 +1,4 @@
ALTER TABLE moderators
ADD admin_status BOOLEAN NOT NULL DEFAULT FALSE;
ALTER TABLE moderators
ADD admin_status BOOLEAN
NOT NULL
DEFAULT FALSE;