Create helper for checking if user is moderator
This commit is contained in:
parent
45614f4035
commit
de8a76271d
|
@ -50,6 +50,14 @@ sub startup($self) {
|
|||
return $truncated_text;
|
||||
});
|
||||
|
||||
$self->helper(is_mod => sub ($c) {
|
||||
if (my $mod_id = $c->session->{'mod_id'}) {
|
||||
return 1 if $mod_id =~ /\d/
|
||||
}
|
||||
|
||||
return undef;
|
||||
});
|
||||
|
||||
# Finish configuring some things
|
||||
$self->secrets($self->config->{'secrets'}) || die $@;
|
||||
|
||||
|
@ -135,7 +143,7 @@ sub startup($self) {
|
|||
|
||||
# Moderator
|
||||
my $moderator = $r->under('/moderator', sub ($c) {
|
||||
return 1 if $c->session('mod_id') =~ /^\d+$/;
|
||||
return 1 if $c->is_mod;
|
||||
|
||||
$c->redirect_to('mod_login');
|
||||
# Return false otherwise a body is rendered with the redirect...
|
||||
|
|
|
@ -8,8 +8,7 @@ sub login($self) {
|
|||
my $v;
|
||||
|
||||
#Already logged in?
|
||||
return $self->redirect_to('mod_list')
|
||||
if defined $self->session->{'mod_id'};
|
||||
return $self->redirect_to('mod_list') if $self->is_mod;
|
||||
|
||||
$v = $self->validation if $self->req->method eq 'POST';
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user