修复手机号认证完成后仍反复弹窗的问题
认证提交接口在仅上传头像时错误返回成功,检查接口也未兼容已有手机号的老数据。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -252,10 +252,24 @@ class CheckPhoneAuthView(APIView):
|
||||
|
||||
permission_classes = [IsAuthenticated]
|
||||
|
||||
def post(self, request):
|
||||
user = request.user
|
||||
@staticmethod
|
||||
def _phone_auth_completed(user):
|
||||
"""是否已完成手机号认证(兼容 PhoneVerified 未写入的老数据)。"""
|
||||
if bool(getattr(user, 'PhoneVerified', False)):
|
||||
return True
|
||||
phone = (getattr(user, 'Phone', None) or '').strip()
|
||||
return len(phone) >= 11
|
||||
|
||||
if getattr(user, 'PhoneVerified', False):
|
||||
def post(self, request):
|
||||
uid = getattr(request.user, 'UserUID', None)
|
||||
user = request.user
|
||||
if uid:
|
||||
try:
|
||||
user = User.query.get(UserUID=uid)
|
||||
except User.DoesNotExist:
|
||||
user = request.user
|
||||
|
||||
if self._phone_auth_completed(user):
|
||||
return Response({'code': 0, 'need_auth': False})
|
||||
|
||||
if self._dashou_meets_threshold(user):
|
||||
|
||||
Reference in New Issue
Block a user