11
This commit is contained in:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user