diff --git a/dashboard/models.py b/dashboard/models.py index 749ea35..3efbd9d 100644 --- a/dashboard/models.py +++ b/dashboard/models.py @@ -102,6 +102,7 @@ class Group_user(models.Model): User, on_delete=models.CASCADE, null=True, blank=True) group = models.ForeignKey( Group, on_delete=models.CASCADE, null=True, blank=True) + status = models.IntegerField('status', default=1) created = models.DateTimeField('创建时间', auto_now_add=True) updated = models.DateTimeField('更新时间', auto_now=True) diff --git a/polls/views/__pycache__/user.cpython-38.pyc b/polls/views/__pycache__/user.cpython-38.pyc index ccdf190..086d6a7 100644 Binary files a/polls/views/__pycache__/user.cpython-38.pyc and b/polls/views/__pycache__/user.cpython-38.pyc differ diff --git a/polls/views/user.py b/polls/views/user.py index 39e4734..1e0a82a 100644 --- a/polls/views/user.py +++ b/polls/views/user.py @@ -198,12 +198,17 @@ def reset_password(request): return HttpResponse(status=405) password = request.POST.get('password') if not password: + return JsonResponse({'status': 'error', 'message': '原密码不能为空'}) + new_password = request.POST.get('newPassword') + if not new_password: return JsonResponse({'status': 'error', 'message': '密码不能为空'}) - if len(password) < 6: + if len(new_password) < 6: return JsonResponse({'status': 'error', 'message': '密码长度不能少于6位'}) user_id = request.user.id UserModel = get_user_model() user = UserModel.objects.get(id=user_id) - user.set_password(password) + if not user.check_password(password): + return JsonResponse({'status': 'error', 'message': '原密码不正确'}) + user.set_password(new_password) user.save() return JsonResponse({'status': 'success', 'message': '密码修改成功'})