revbank/plugins/adduser
2022-06-11 16:31:44 +02:00

28 lines
675 B
Perl

#!perl
HELP1 "adduser <name>" => "Create an account";
sub command :Tab(adduser) ($self, $cart, $command, @) {
$command eq 'adduser' or return NEXT;
if ($cart->size) {
return ABORT, "Create the account *before* scanning things.";
}
return "Name for the new account", \&username;
}
sub username($self, $cart, $name, @) {
return REJECT, "Sorry, whitespace is not allowed."
if $name =~ /\s/;
return REJECT, "That's too numeric to be a user name."
if defined parse_amount($name);
return REJECT, "That name already exists."
if defined parse_user($name);
RevBank::Users::create( $name );
return ACCEPT;
}