mirror of
https://github.com/QingdaoU/OnlineJudge.git
synced 2024-09-21 16:33:22 +00:00
修改检测邮箱api使其可以被重置密码页面使用
This commit is contained in:
parent
9cd52115fc
commit
e191fa0dd8
@ -149,17 +149,27 @@ class UsernameCheckAPIView(APIView):
|
|||||||
class EmailCheckAPIView(APIView):
|
class EmailCheckAPIView(APIView):
|
||||||
def get(self, request):
|
def get(self, request):
|
||||||
"""
|
"""
|
||||||
检测邮箱是否存在,存在返回状态码400,不存在返回200
|
检测邮箱是否存在,用状态码标识结果
|
||||||
---
|
---
|
||||||
"""
|
"""
|
||||||
|
#这里是为了适应前端表单验证空间的要求
|
||||||
|
reset = request.GET.get("reset", None)
|
||||||
|
#如果reset为true说明该请求是重置密码页面发出的,要返回的状态码应正好相反
|
||||||
|
if reset:
|
||||||
|
existed = 200
|
||||||
|
does_not_existed = 400
|
||||||
|
else:
|
||||||
|
existed = 400
|
||||||
|
does_not_existed = 200
|
||||||
|
|
||||||
email = request.GET.get("email", None)
|
email = request.GET.get("email", None)
|
||||||
if email:
|
if email:
|
||||||
try:
|
try:
|
||||||
User.objects.get(email=email)
|
User.objects.get(email=email)
|
||||||
return Response(status=400)
|
return Response(status=existed)
|
||||||
except Exception:
|
except Exception:
|
||||||
return Response(status=200)
|
return Response(status=does_not_existed)
|
||||||
return Response(status=200)
|
return Response(status=does_not_existed)
|
||||||
|
|
||||||
|
|
||||||
class UserAdminAPIView(APIView):
|
class UserAdminAPIView(APIView):
|
||||||
|
Loading…
Reference in New Issue
Block a user