New command: adduser
Creating users with 'deposit' was hard to explain.
This commit is contained in:
parent
f3e90cf710
commit
3489793a97
2 changed files with 39 additions and 2 deletions
32
plugins/adduser
Executable file
32
plugins/adduser
Executable file
|
@ -0,0 +1,32 @@
|
|||
#!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;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue