Use perlcritic theme; add is_admin() helper; clean up some things
This commit is contained in:
parent
4527219d91
commit
5cce06c984
|
@ -1 +1 @@
|
|||
exclude = Subroutines::ProhibitSubroutinePrototypes
|
||||
theme = community
|
||||
|
|
1
cpanfile
1
cpanfile
|
@ -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';
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue