add message
This commit is contained in:
parent
bb69aa45bd
commit
5a2529e12e
|
@ -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)
|
||||
|
||||
|
|
Binary file not shown.
|
@ -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': '密码修改成功'})
|
||||
|
|
Loading…
Reference in New Issue