v6.1.0: improve handling of invalid balance in revbank.accounts
This small change makes it possible to reserve an account name by just giving it an invalid balance in `revbank.accounts`.
This commit is contained in:
parent
4e2115f265
commit
33b08f99ea
2 changed files with 12 additions and 4 deletions
|
@ -98,13 +98,18 @@ sub is_special($username) {
|
||||||
return $username =~ /^[-+*]/;
|
return $username =~ /^[-+*]/;
|
||||||
}
|
}
|
||||||
|
|
||||||
sub parse_user($username) {
|
sub parse_user($username, $allow_invalid = 0) {
|
||||||
return undef if is_hidden($username);
|
return undef if is_hidden($username);
|
||||||
|
|
||||||
my $users = _read();
|
my $users = _read();
|
||||||
return exists $users->{ lc $username }
|
|
||||||
? $users->{ lc $username }->[0]
|
exists $users->{ lc $username }
|
||||||
: undef;
|
or return undef;
|
||||||
|
|
||||||
|
$allow_invalid or defined balance($username)
|
||||||
|
or return undef;
|
||||||
|
|
||||||
|
return $users->{ lc $username }->[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
sub assert_user($username) {
|
sub assert_user($username) {
|
||||||
|
|
|
@ -27,6 +27,9 @@ sub username($self, $cart, $name, @) {
|
||||||
return REJECT, "That name already exists."
|
return REJECT, "That name already exists."
|
||||||
if defined parse_user($name);
|
if defined parse_user($name);
|
||||||
|
|
||||||
|
return REJECT, "That name is not available."
|
||||||
|
if defined parse_user($name, 1);
|
||||||
|
|
||||||
for my $plugin (RevBank::Plugins->new) {
|
for my $plugin (RevBank::Plugins->new) {
|
||||||
my $id = $plugin->id;
|
my $id = $plugin->id;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue