diff --git a/README.md b/README.md index 6283a75..b7bf07d 100644 --- a/README.md +++ b/README.md @@ -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) diff --git a/lib/PostText/Model/Moderator.pm b/lib/PostText/Model/Moderator.pm index 77222f2..9efc34f 100644 --- a/lib/PostText/Model/Moderator.pm +++ b/lib/PostText/Model/Moderator.pm @@ -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;