def check_password(self): username = self.cleaned_data['username'] password = self.cleaned_data['password'] try: user = User.objects.get(username=username) return user,auth_check_password(password,user.password) except: return None,False
def check_password(self): print('check password') student_id = self.cleaned_data['student_id'] password = self.cleaned_data['password'] try: student_id = User.objects.get(student_id=student_id) return student_id, auth_check_password(password, student_id.password) except: return None, False
def check_password(self): print('check password') mobile = self.cleaned_data['mobile_pwlogin'] password = self.cleaned_data['password_login'] try: user = User.objects.get(mobile=mobile) print(user.username) return user, auth_check_password(password, user.password) except: return None, False
def post(self,request): ret = {"status": 400, "msg": "调用方式错误"} oldpassword = request.POST.get("oldpassword") newpasswd1 = request.POST.get("newpassword1") if auth_check_password(oldpassword, request.user.password): request.user.password=make_password(newpasswd1) logger.info(f"{request.user.username}注销成功") logger.info(f"{request.user.username}修改密码成功") request.user.save() return render(request,'house/index.html',{"msg":"修改密码成功,请重新登录"}) else: ret ={"status": 300, "msg": "旧密码错误"} return render(request,"uc/uc_change_passwd.html",{"msg":"旧密码错误"})