管理员修改用户信息的时候,也应该不区分用户名和邮箱的大小写

This commit is contained in:
virusdefender 2018-05-06 02:14:46 +08:00
parent e843404c5f
commit ab37c98347

View File

@ -54,14 +54,14 @@ class UserAdminAPI(APIView):
user = User.objects.get(id=data["id"])
except User.DoesNotExist:
return self.error("User does not exist")
if User.objects.filter(username=data["username"]).exclude(id=user.id).exists():
if User.objects.filter(username=data["username"].lower()).exclude(id=user.id).exists():
return self.error("Username already exists")
if User.objects.filter(email=data["email"].lower()).exclude(id=user.id).exists():
return self.error("Email already exists")
pre_username = user.username
user.username = data["username"]
user.email = data["email"]
user.username = data["username"].lower()
user.email = data["email"].lower()
user.admin_type = data["admin_type"]
user.is_disabled = data["is_disabled"]