Add method for creating moderator

This commit is contained in:
swag 2023-01-08 22:41:59 -05:00
parent d9a18ffa44
commit 6be8cc43a9
2 changed files with 13 additions and 0 deletions

View File

@ -32,6 +32,7 @@ Run the tests locally (against development environment):
## TODOs
1. Increment last_login_date when loggin in!!
1. Actions for creating moderators and resetting passwords
1. CSS
1. "All new posts flagged" mode (require approval for new posts)

View File

@ -4,6 +4,18 @@ use Mojo::Base -base, -signatures;
has [qw{pg authenticator}];
sub create($self, $name, $email, $password) {
my $password_hash = $self->authenticator->hash_password($password);
$self->pg->db->query(<<~'END_SQL', $name, $email, $password_hash);
INSERT INTO moderators
(moderator_name,
email_addr,
password_hash)
VALUES (?, ?, ?);
END_SQL
}
sub check($self, $email, $password) {
my $moderator =
$self->pg->db->query(<<~'END_SQL', $email)->hash;