修改检测邮箱api使其可以被重置密码页面使用

This commit is contained in:
sxw 2015-11-29 09:39:39 +08:00
parent 9cd52115fc
commit e191fa0dd8

View File

@ -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):