bank: auto-account username prefix goa-bank-acc-<id>
Personal auto-accounts use usernames of the form goa-bank-acc- plus a random hex id so they are easy to spot in admin lists and distinct from explorer or hand-registered users.
This commit is contained in:
parent
f341116371
commit
bb7bd5e73c
1 changed files with 7 additions and 4 deletions
|
|
@ -124,9 +124,8 @@ def mint_withdraw() -> dict:
|
||||||
|
|
||||||
|
|
||||||
def _rand_username() -> str:
|
def _rand_username() -> str:
|
||||||
# bank usernames: keep simple [a-z0-9]
|
# goa-bank-acc-<uuid> — unique guest id, bank-safe [a-z0-9-]
|
||||||
alphabet = string.ascii_lowercase + string.digits
|
return "goa-bank-acc-" + secrets.token_hex(8)
|
||||||
return "guest" + "".join(secrets.choice(alphabet) for _ in range(8))
|
|
||||||
|
|
||||||
|
|
||||||
def _rand_password() -> str:
|
def _rand_password() -> str:
|
||||||
|
|
@ -139,7 +138,9 @@ def create_personal_account() -> dict:
|
||||||
"""Public registration: auto username/password, balance starts at 0."""
|
"""Public registration: auto username/password, balance starts at 0."""
|
||||||
username = _rand_username()
|
username = _rand_username()
|
||||||
password = _rand_password()
|
password = _rand_password()
|
||||||
name = "Guest " + username[5:9].upper()
|
# short label from id suffix
|
||||||
|
suffix = username.rsplit("-", 1)[-1][:8]
|
||||||
|
name = "GOA bank acc " + suffix
|
||||||
code, body = http_json(
|
code, body = http_json(
|
||||||
"POST",
|
"POST",
|
||||||
f"{BANK}/accounts",
|
f"{BANK}/accounts",
|
||||||
|
|
@ -153,6 +154,8 @@ def create_personal_account() -> dict:
|
||||||
# retry once on conflict
|
# retry once on conflict
|
||||||
if code in (409, 400):
|
if code in (409, 400):
|
||||||
username = _rand_username()
|
username = _rand_username()
|
||||||
|
suffix = username.rsplit("-", 1)[-1][:8]
|
||||||
|
name = "GOA bank acc " + suffix
|
||||||
code, body = http_json(
|
code, body = http_json(
|
||||||
"POST",
|
"POST",
|
||||||
f"{BANK}/accounts",
|
f"{BANK}/accounts",
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue