diff --git a/lib/PostText/Command/argon2.pm b/lib/PostText/Command/argon2.pm index bc2085e..fd6e872 100644 --- a/lib/PostText/Command/argon2.pm +++ b/lib/PostText/Command/argon2.pm @@ -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 } diff --git a/lib/PostText/Command/create.pm b/lib/PostText/Command/create.pm new file mode 100644 index 0000000..c3236cf --- /dev/null +++ b/lib/PostText/Command/create.pm @@ -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 diff --git a/lib/PostText/Command/promote.pm b/lib/PostText/Command/promote.pm new file mode 100644 index 0000000..4c2d53a --- /dev/null +++ b/lib/PostText/Command/promote.pm @@ -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