Allow mods to re-register/reset their password (#37)

reminder^2
Etzelia 2019-09-30 21:43:13 +02:00 committed by Gitea
parent d658f5fa85
commit 3af8642ff0
1 changed files with 5 additions and 3 deletions

View File

@ -279,11 +279,13 @@ class PluginAPI(View):
json['message'] = "Updated {0}".format(post['username'])
elif "register" == keyword:
player = Player.objects.get(uuid=post['uuid'])
if player.auth_user:
json['status'] = False
json['message'] = "You are already registered. To change your password, contact an Admin."
else:
password = mcm_api.generate_password()
if player.auth_user:
player.auth_user.password = password
player.auth_user.is_active = True
player.auth_user.save()
json['message'] = password
else:
user = User.objects.create_user(username=player.username.lower(), password=password)
user.save()
player.auth_user = user