revbank/plugins/adduser
Juerd Waalboer 3489793a97 New command: adduser
Creating users with 'deposit' was hard to explain.
2019-03-09 22:47:50 +01:00

32 lines
698 B
Perl
Executable file

#!perl
HELP "adduser <name>" => "Create an account";
sub command :Tab(adduser) {
my ($self, $cart, $command) = @_;
$command eq 'adduser' or return NEXT;
if ($cart->size) {
return REJECT, "Create the account *before* scanning things.";
}
return "Name for the new account", \&username;
}
sub username {
my ($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;
}