From 6e9775f530a1f5afc7ab3ca8342881cd36ea5e03 Mon Sep 17 00:00:00 2001 From: aaron <> Date: Sun, 9 Mar 2025 09:56:54 +0800 Subject: [PATCH] update --- app/api/endpoints/user.py | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/app/api/endpoints/user.py b/app/api/endpoints/user.py index 4607a3b..4700bfa 100644 --- a/app/api/endpoints/user.py +++ b/app/api/endpoints/user.py @@ -329,9 +329,20 @@ async def password_login( if not verify_password(login_data.password, user.password): return error_response(code=401, message="密码错误") - if login_data.role == UserRole.ADMIN: - if UserRole.ADMIN not in user.roles: - return error_response(code=401, message="管理员账户,请先设置管理员角色") + if login_data.role == UserRole.ADMIN and UserRole.ADMIN not in user.roles: + return error_response(code=401, message="你没有登录权限") + + if login_data.role == UserRole.PARTNER and UserRole.PARTNER not in user.roles: + return error_response(code=401, message="你没有登录权限") + + if login_data.role == UserRole.MERCHANT and UserRole.MERCHANT not in user.roles: + return error_response(code=401, message="你没有登录权限") + + if login_data.role == UserRole.DELIVERYMAN and UserRole.DELIVERYMAN not in user.roles: + return error_response(code=401, message="你没有登录权限") + + if login_data.role == UserRole.USER and UserRole.USER not in user.roles: + return error_response(code=401, message="你没有登录权限") if login_data.role == UserRole.MERCHANT and UserRole.MERCHANT in user.roles: # 检查是否有商家设置了当前用户 id