PostText/lib/PostText/Model/Moderator.pm
2022-11-19 23:55:03 -05:00

24 lines
531 B
Perl

package PostText::Model::Moderator;
use Mojo::Base -base, -signatures;
has 'pg';
has 'authenticator';
sub check($self, $email, $password) {
my $moderator =
$self->pg->db->query(<<~'END_SQL', $email)->hash;
SELECT moderator_id AS id,
password_hash
FROM moderators
WHERE email_addr = ?;
END_SQL
return undef unless $moderator->{'id'};
return $self->authenticator
->verify_password($password, $moderator->{'password_hash'});
}
1;