From 3489793a97689822881c496fb6b102aad040a740 Mon Sep 17 00:00:00 2001 From: Juerd Waalboer Date: Sat, 9 Mar 2019 22:47:50 +0100 Subject: [PATCH] New command: adduser Creating users with 'deposit' was hard to explain. --- plugins/adduser | 32 ++++++++++++++++++++++++++++++++ revbank.plugins | 9 +++++++-- 2 files changed, 39 insertions(+), 2 deletions(-) create mode 100755 plugins/adduser diff --git a/plugins/adduser b/plugins/adduser new file mode 100755 index 0000000..15a07de --- /dev/null +++ b/plugins/adduser @@ -0,0 +1,32 @@ +#!perl + +HELP "adduser " => "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; +} diff --git a/revbank.plugins b/revbank.plugins index c3442c3..ac08ca5 100644 --- a/revbank.plugins +++ b/revbank.plugins @@ -11,13 +11,16 @@ undo give grandtotal take -nyan # fun, but not compatible with dumb terminals pfand # makes little sense in a self service environment stock +unlisted +#warnings +adduser beep_terminal -game # Scan-foo game +#nyan # fun, but not compatible with dumb terminals +#game # Scan-foo game # Then, plugins that apply heuristics @@ -26,3 +29,5 @@ market # also matches product IDs withdraw # matches amounts users # matches usernames deposit # wants to be after 'users' +#deposit_methods # Extra options for 'deposit'. Edit/configure first! +repeat