Added commands for creating and promoting accounts
This commit is contained in:
parent
28c914565f
commit
25e370bba5
|
@ -6,6 +6,8 @@ has description => 'Hash a string with Argon2';
|
|||
has usage => sub ($self) { $self->extract_usage };
|
||||
|
||||
sub run($self, @args) {
|
||||
die $self->usage unless $args[0];
|
||||
|
||||
say $self->app->authenticator->hash_password($_) for @args
|
||||
}
|
||||
|
||||
|
|
31
lib/PostText/Command/create.pm
Normal file
31
lib/PostText/Command/create.pm
Normal file
|
@ -0,0 +1,31 @@
|
|||
package PostText::Command::create;
|
||||
|
||||
use Mojo::Base 'Mojolicious::Command', -signatures;
|
||||
use Mojo::Util qw{getopt};
|
||||
|
||||
has description => 'Create a moderator account';
|
||||
has usage => sub ($self) { $self->extract_usage };
|
||||
|
||||
sub run($self, @args) {
|
||||
die $self->usage unless $args[0];
|
||||
|
||||
getopt \@args,
|
||||
'n|name=s' => \my $name,
|
||||
'e|email=s' => \my $email,
|
||||
'p|password=s' => \my $password;
|
||||
|
||||
say 'Moderator created successfully.'
|
||||
if $self->app->moderator->create($name, $email, $password);
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
Usage: APPLICATION create OPTIONS
|
||||
|
||||
Options:
|
||||
-n, --name Moderator's name
|
||||
-e, --email Moderator's email
|
||||
-p, --password Moderator's password
|
||||
=cut
|
22
lib/PostText/Command/promote.pm
Normal file
22
lib/PostText/Command/promote.pm
Normal file
|
@ -0,0 +1,22 @@
|
|||
package PostText::Command::promote;
|
||||
|
||||
use Mojo::Base 'Mojolicious::Command', -signatures;
|
||||
|
||||
has description => 'Promote a moderator account to admin';
|
||||
has usage => sub ($self) { $self->extract_usage };
|
||||
|
||||
sub run($self, @args) {
|
||||
die $self->usage unless $args[0];
|
||||
|
||||
for my $email (@args) {
|
||||
say "Promoted $email." if $self->app->moderator->promote($email)
|
||||
}
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
Usage: APPLICATION EMAIL(S)
|
||||
|
||||
=cut
|
Loading…
Reference in a new issue