From ae739693204345fef63031e24d8c6442251c1607 Mon Sep 17 00:00:00 2001 From: swag Date: Sun, 8 Jan 2023 23:53:30 -0500 Subject: [PATCH] Too easy to not just do this now --- README.md | 1 - lib/PostText.pm | 2 +- lib/PostText/Model/Moderator.pm | 8 ++++++++ 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 9fb8ff5..6283a75 100644 --- a/README.md +++ b/README.md @@ -41,7 +41,6 @@ Run the tests locally (against development environment): ### (Lord knows there's TODOs I could be working on...) 1. RSS feed!! -1. Log user out if locked out? Will need to check `lock_status()` beyond just logging in 1. Support at least some Markdown, specifically the code blocks 1. Implement tripcodes (moving this down in priority due to complexity...) 1. Return a text response instead of HTML if a `.txt` extension [is diff --git a/lib/PostText.pm b/lib/PostText.pm index d76dab6..36e023c 100644 --- a/lib/PostText.pm +++ b/lib/PostText.pm @@ -52,7 +52,7 @@ sub startup($self) { $self->helper(is_mod => sub ($c) { if (my $mod_id = $c->session->{'mod_id'}) { - return 1 if $mod_id =~ /\d+/ + return 1 unless $c->moderator->lock_status($mod_id) } return undef; diff --git a/lib/PostText/Model/Moderator.pm b/lib/PostText/Model/Moderator.pm index 527ce43..2c8597b 100644 --- a/lib/PostText/Model/Moderator.pm +++ b/lib/PostText/Model/Moderator.pm @@ -45,6 +45,14 @@ sub lock_out($self, $mod_id) { END_SQL } +sub unlock($self, $mod_id) { + $self->pg->db->query(<<~'END_SQL', $mod_id) + UPDATE moderators + SET lock_status = FALSE + WHERE moderator_id = ?; + END_SQL +} + sub get_id($self, $email) { $self->pg->db->query(<<~'END_SQL', $email)->hash->{'moderator_id'} SELECT moderator_id