feat(auth): 默认昵称加“用户”前缀(用户+9 位随机串) (#70)
新用户注册即分配的默认昵称由 9 位字母数字随机串改为“用户”+9 位随机串(如 用户aB3xK9mP2),更友好可读;长度 11 仍在 nickname(64)与改名上限(20)内。同步更新 test_login_assigns_username_and_nickname 断言。 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> --------- Co-authored-by: zzhyyyyy <2685922758@qq.com> Reviewed-on: #70 Co-authored-by: zhuzihao <zhuzihao@wonderable.ai> Co-committed-by: zhuzihao <zhuzihao@wonderable.ai>
This commit was merged in pull request #70.
This commit is contained in:
+4
-2
@@ -211,7 +211,7 @@ def test_sms_gc_purges_stale_only(monkeypatch) -> None:
|
||||
# ============================ 用户名 / 默认昵称 ============================
|
||||
|
||||
def test_login_assigns_username_and_nickname(client) -> None:
|
||||
"""新用户创建即分配:11 位纯数字 username(首位非 0/1,与手机号天然区分)+ 9 位字母数字默认昵称。"""
|
||||
"""新用户创建即分配:11 位纯数字 username(首位非 0/1,与手机号天然区分)+ "用户"+9 位字母数字默认昵称。"""
|
||||
phone = "13600136000"
|
||||
client.post("/api/v1/auth/sms/send", json={"phone": phone})
|
||||
r = client.post("/api/v1/auth/sms/login", json={"phone": phone, "code": "123456"})
|
||||
@@ -223,7 +223,9 @@ def test_login_assigns_username_and_nickname(client) -> None:
|
||||
assert uname[0] not in ("0", "1") # 无前导 0、与手机号(均以 1 开头)区分
|
||||
|
||||
nick = user["nickname"]
|
||||
assert nick and len(nick) == 9 and nick.isalnum() # 9 位字母+数字
|
||||
assert nick.startswith("用户") # "用户" 前缀
|
||||
suffix = nick.removeprefix("用户")
|
||||
assert len(suffix) == 9 and suffix.isalnum() # 后接 9 位字母+数字
|
||||
|
||||
|
||||
def test_username_stable_and_unique_on_relogin() -> None:
|
||||
|
||||
Reference in New Issue
Block a user