forked from Minecraft/minecraft_manager
Allow mods to re-register/reset their password (#37)
parent
d658f5fa85
commit
3af8642ff0
|
@ -279,11 +279,13 @@ class PluginAPI(View):
|
|||
json['message'] = "Updated {0}".format(post['username'])
|
||||
elif "register" == keyword:
|
||||
player = Player.objects.get(uuid=post['uuid'])
|
||||
password = mcm_api.generate_password()
|
||||
if player.auth_user:
|
||||
json['status'] = False
|
||||
json['message'] = "You are already registered. To change your password, contact an Admin."
|
||||
player.auth_user.password = password
|
||||
player.auth_user.is_active = True
|
||||
player.auth_user.save()
|
||||
json['message'] = password
|
||||
else:
|
||||
password = mcm_api.generate_password()
|
||||
user = User.objects.create_user(username=player.username.lower(), password=password)
|
||||
user.save()
|
||||
player.auth_user = user
|
||||
|
|
Loading…
Reference in New Issue