Merge remote-tracking branch 'origin/master'

This commit is contained in:
Bob 2020-10-26 00:01:00 +08:00
commit 00341f9dc6
3 changed files with 11 additions and 2 deletions

View File

@ -63,6 +63,9 @@ class Group(models.Model):
def __str__(self): def __str__(self):
return self.name return self.name
class Meta:
ordering = ["rank"]
# 矩阵管理员 # 矩阵管理员
@ -99,6 +102,7 @@ class Group_user(models.Model):
User, on_delete=models.CASCADE, null=True, blank=True) User, on_delete=models.CASCADE, null=True, blank=True)
group = models.ForeignKey( group = models.ForeignKey(
Group, on_delete=models.CASCADE, null=True, blank=True) Group, on_delete=models.CASCADE, null=True, blank=True)
status = models.IntegerField('status', default=1)
created = models.DateTimeField('创建时间', auto_now_add=True) created = models.DateTimeField('创建时间', auto_now_add=True)
updated = models.DateTimeField('更新时间', auto_now=True) updated = models.DateTimeField('更新时间', auto_now=True)

View File

@ -198,12 +198,17 @@ def reset_password(request):
return HttpResponse(status=405) return HttpResponse(status=405)
password = request.POST.get('password') password = request.POST.get('password')
if not password: if not password:
return JsonResponse({'status': 'error', 'message': '原密码不能为空'})
new_password = request.POST.get('newPassword')
if not new_password:
return JsonResponse({'status': 'error', 'message': '密码不能为空'}) return JsonResponse({'status': 'error', 'message': '密码不能为空'})
if len(password) < 6: if len(new_password) < 6:
return JsonResponse({'status': 'error', 'message': '密码长度不能少于6位'}) return JsonResponse({'status': 'error', 'message': '密码长度不能少于6位'})
user_id = request.user.id user_id = request.user.id
UserModel = get_user_model() UserModel = get_user_model()
user = UserModel.objects.get(id=user_id) 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() user.save()
return JsonResponse({'status': 'success', 'message': '密码修改成功'}) return JsonResponse({'status': 'success', 'message': '密码修改成功'})