This commit is contained in:
aaron 2025-02-17 14:42:06 +08:00
parent 6fbb3c44f2
commit f421c3d097

View File

@ -309,17 +309,17 @@ async def password_login(
if not verify_password(login_data.password, user.password):
return error_response(code=401, message="密码错误")
if login_data.platform == Platform.ADMIN:
if login_data.role == UserRole.ADMIN:
if UserRole.ADMIN not in user.roles:
return error_response(code=401, message="管理员账户,请先设置管理员角色")
if login_data.platform == Platform.MERCHANT and UserRole.MERCHANT in user.roles:
if login_data.role == UserRole.MERCHANT and UserRole.MERCHANT in user.roles:
# 检查是否有商家设置了当前用户 id
merchant = db.query(MerchantDB).filter(MerchantDB.user_id == user.userid).first()
if not merchant:
return error_response(code=401, message="商家账户,请先关联商家")
if login_data.platform == Platform.DELIVERYMAN and UserRole.DELIVERYMAN in user.roles and not user.community_id:
if login_data.role == UserRole.DELIVERYMAN and UserRole.DELIVERYMAN in user.roles and not user.community_id:
return error_response(code=401, message="配送员账户,请先设置归属小区")
# 生成访问令牌