This commit is contained in:
fengchuanhn@gmail.com
2026-05-22 14:59:33 +08:00
parent 3c91a52aff
commit 5aafba8eb9
5 changed files with 40 additions and 2 deletions

View File

@@ -66,12 +66,18 @@ async def register_user(
if existing is not None:
raise AuthError("用户名已存在")
serial = _normalize_device_serial(device_serial)
if serial:
bound = await db.scalar(select(User).where(User.device_serial == serial))
if bound is not None:
raise AuthError("该电脑已绑定其它用户")
user = User(
username=username,
password_hash=hash_password(password),
role_id=0,
phone=None,
device_serial=_normalize_device_serial(device_serial),
device_serial=serial,
)
db.add(user)
await db.flush()