fix: 后台停用/禁用真正生效(重复集团任职与超管绕过)
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -148,12 +148,27 @@ class ClubKefuLoginView(APIView):
|
||||
if not user.CheckPassword(password):
|
||||
continue
|
||||
password_matched = True
|
||||
|
||||
from jituan.services.admin_context import is_hardcoded_super_phone
|
||||
try:
|
||||
kefu_probe = user.KefuProfile
|
||||
except Exception:
|
||||
kefu_probe = None
|
||||
if kefu_probe is not None and int(getattr(kefu_probe, 'zhuangtai', 1) or 0) != 1:
|
||||
if not is_hardcoded_super_phone(user):
|
||||
if target_user is None:
|
||||
target_user = user
|
||||
target_kefu = kefu_probe
|
||||
continue
|
||||
|
||||
is_admin = user.IsSuperuser or user.UserType == 'admin' or user.Phone in SUPER_ADMIN_PHONES
|
||||
if is_admin:
|
||||
target_user = user
|
||||
target_kefu = None
|
||||
target_kefu = kefu_probe
|
||||
break
|
||||
kefu = user.KefuProfile
|
||||
kefu = kefu_probe
|
||||
if kefu is None:
|
||||
continue
|
||||
stored_erji = kefu.erjimima or ''
|
||||
if stored_erji.startswith(('$2b$', '$2a$')) and len(stored_erji) == 60:
|
||||
import bcrypt as _bcrypt
|
||||
@@ -170,7 +185,7 @@ class ClubKefuLoginView(APIView):
|
||||
target_kefu = kefu
|
||||
break
|
||||
else:
|
||||
if target_user and target_kefu:
|
||||
if target_user and target_kefu and int(getattr(target_kefu, 'zhuangtai', 1) or 0) != 1:
|
||||
return Response({'code': 4, 'msg': '账号已被封禁', 'data': None},
|
||||
status=status.HTTP_403_FORBIDDEN)
|
||||
if password_matched:
|
||||
|
||||
Reference in New Issue
Block a user