mirror of
https://github.com/QingdaoU/OnlineJudge.git
synced 2024-12-29 16:41:56 +00:00
管理员修改用户信息的时候,也应该不区分用户名和邮箱的大小写
This commit is contained in:
parent
e843404c5f
commit
ab37c98347
@ -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"]
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user