Beispiel #1
0
    def post(self, request):
        print('验证开始')
        modify_form = ModifyPwdForm(request.POST)
        if modify_form.is_valid():

            print('验证成功')

            pwd1 = request.POST.get('password1', '')
            pwd2 = request.POST.get('password2', '')
            print('0---->', pwd1, pwd2)
            email = request.POST.get('email', '')

            if pwd1 != pwd2:

                return render(request, 'password_reset.html', {
                    'email': email,
                    'msg': "密码不一致"
                })
            user = UserProfile.objects.get(email=email)
            user.password = make_password(pwd2)

            user.save()
            return render(request, 'login.html')
        else:

            print '验证失败'
            email = request.POST.get('email', '')
            return render(request, 'password_reset.html', {
                'email': email,
                'modify_form': modify_form
            })
Beispiel #2
0
 def post(self, request):
     modify_form = ModifyPwdForm(request.POST)
     email = request.POST.get("email", "")
     if modify_form.is_valid():
         password = request.POST.get("password", "")
         user = UserProfile.objects.get(email=email)
         if user:
             user.password = make_password(password)
             user.save()
             return render(request, "login.html")
             return render(request, "send_success.html")
     else:
         return render(request, "password_reset.html", {"email": email})
Beispiel #3
0
 def post(self, request):
     modify_form = ModifyPwdForm(request.POST)
     if modify_form.is_valid():
         pwd1 = request.POST.get("password1", "")
         pwd2 = request.POST.get("password2", "")
         if pwd1 != pwd2:
             return JsonResponse({"status": "fail", "msg": "密码不一致!"})
         user = request.user
         user.password = make_password(pwd2)
         user.save()
         return JsonResponse({"status": "success", "msg": "密码修改成功!"})
     else:
         return HttpResponse(json.dumps(modify_form.errors))
Beispiel #4
0
    def post(self, request):

        modify_form = ModifyPwdForm(request.POST)
        if modify_form.is_valid():
            pwd1 = request.POST.get("password1", "")
            pwd2 = request.POST.get("password2", "")
            if pwd1 != pwd2:
                return HttpResponse('{"status":"fail", "msg": "两次密码不一致,请重新输入"}', content_type='application/json')
            user = request.user
            user.password = make_password(pwd2)
            user.save()
            return HttpResponse('{"status":"success"}', content_type='application/json')
        else:
            return HttpResponse(json.dumps(modify_form.errors), content_type='application/json')
Beispiel #5
0
 def post(self, request):
     modify_form = ModifyPwdForm(request.POST)
     if modify_form.is_valid():
         pwd1 = request.POST.get("password1", "")
         pwd2 = request.POST.get("password2", "")
         email = request.POST.get("email", "")
         if pwd1 != pwd2:
             return render(request, "password_reset.html", {"email": email, "msg": "密码不一致"})
         user = UserProfile.objects.get(email=email)
         user.password = make_password(pwd2)
         user.save()
         return render(request, "login.html")
     else:
         email = request.POST.get("email", "")
         return render(request, "password_reset.html", {"email": email, "modify_form": modify_form})
Beispiel #6
0
 def post(self, request):
     modify_form = ModifyPwdForm(request.POST)
     if modify_form.is_valid():
         pwd1 = request.POST.get('password1', "")
         pwd2 = request.POST.get('password2', "")
         email = request.POST.get('email', "")
         if pwd1 != pwd2:
             return render(request, 'password_reset.html', {'email': email, 'msg': '密码不一致'})
         user = UserProfile.objects.get(email=email)
         user.password = make_password(pwd1)
         user.save()
         return render(request, 'login.html')
     else:
         email = request.POST.get('email', "")
         return render(request, 'password_reset.html', {'email': email, 'modify_form': modify_form})
Beispiel #7
0
 def post(self, request):
     modify_form = ModifyPwdForm(request.POST)
     if modify_form.is_valid():
         pwd1 = request.POST.get("password1", '')
         pwd2 = request.POST.get("password2", '')
         if pwd1 != pwd2:
             return HttpResponse({
                 "status": "fail",
                 'msg': "密码不一致!"
             },
                                 content_type="application/json")
         user = request.user
         user.password = make_password(pwd2)
         user.save()
         return HttpResponse({"status": "success"},
                             content_type="application/json")
     else:
         return HttpResponse(json.dumps(modify_form.errors),
                             content_type="application/json")
Beispiel #8
0
    def post(self, request):
        print('开始验证')

        modify_form = ModifyPwdForm(request.POST)
        if modify_form.is_valid():
            pwd1 = request.POST.get('password1', '')
            pwd2 = request.POST.get('password2', '')
            print(pwd1, pwd2)

            if pwd1 != pwd2:
                return HttpResponse('{"status":"fail","msg":"密码不一致"}',
                                    content_type='application/json')
            user = request.user
            user.password = make_password(pwd2)
            user.save()
            return render(request, 'login.html')
        else:
            import json

            return HttpResponse(json.dumps(modify_form.errors),
                                content_type='application/json')
Beispiel #9
0
    def post(self, request):
        modify_form = ModifyPwdForm(request.POST)
        if modify_form.is_valid():
            pw1 = request.POST.get("password1", "")
            pw2 = request.POST.get("password2", "")
            email = request.POST.get("email", "")
            if pw1 != pw2:
                return render(request, "password_reset.html", {
                    "email": email,
                    "msg": "密码前后不一致!"
                })
            else:
                user = UserProfile.objects.get(email=email)
                user.password = make_password(
                    pw2)  #数据库中修改,密码为密文所有使用make_password函数
                user.save()  #保存

                return render(request, "login.html")
        else:
            email = request.POST.get("email", "")
            return render(request, "password_reset.html", {
                "email": email,
                "modify_form": modify_form
            })


# def user_login(request):
#     if request.method == "POST":
#         user_name = request.POST.get("username","")
#         pass_word = request.POST.get("password","")
#         user = authenticate(username=user_name,password=pass_word)   #认证方法
#         if user is not None:
#             login(request,user)
#             return render(request,"index.html",{})
#         else:
#             return render(request,"login.html",{"msg":"用户名或密码错误!"})
#     elif request.method == "GET":
#         return render(request,"login.html",{})