mirror of
https://github.com/Casvt/MIND.git
synced 2026-04-25 03:00:20 -04:00
Allow changing username
This commit is contained in:
@@ -208,7 +208,7 @@ def api_add_user(inputs: Dict[str, str]):
|
||||
def api_manage_user(inputs: Dict[str, Any]):
|
||||
user = api_key_map[g.hashed_api_key].user_data
|
||||
if request.method == 'PUT':
|
||||
user.update(None, inputs['new_password'])
|
||||
user.update(inputs['new_username'], inputs['new_password'])
|
||||
return return_api({})
|
||||
|
||||
elif request.method == 'DELETE':
|
||||
@@ -581,7 +581,7 @@ def api_admin_users(inputs: Dict[str, Any]):
|
||||
def api_admin_user(inputs: Dict[str, Any], u_id: int):
|
||||
user = users.get_one(u_id)
|
||||
if request.method == 'PUT':
|
||||
user.update(None, inputs['new_password'])
|
||||
user.update(inputs['new_username'], inputs['new_password'])
|
||||
return return_api({})
|
||||
|
||||
elif request.method == 'DELETE':
|
||||
|
||||
@@ -137,10 +137,16 @@ class CreateUsernameVariable(UsernameVariable):
|
||||
]
|
||||
|
||||
|
||||
class NewPasswordVariable(InputVariable):
|
||||
class NewUsernameVariable(NonRequiredInputVariable):
|
||||
name = "new_username"
|
||||
description = "The new username of the user account"
|
||||
related_exceptions = [InvalidKeyValue, UsernameInvalid, UsernameTaken]
|
||||
|
||||
|
||||
class NewPasswordVariable(NonRequiredInputVariable):
|
||||
name = "new_password"
|
||||
description = "The new password of the user account"
|
||||
related_exceptions = [KeyNotFound]
|
||||
related_exceptions = [InvalidKeyValue]
|
||||
|
||||
|
||||
class TitleVariable(InputVariable):
|
||||
@@ -470,7 +476,7 @@ class UsersData(EndpointData):
|
||||
methods = Methods(
|
||||
put=(
|
||||
"Change the password of the user account",
|
||||
[NewPasswordVariable]
|
||||
[NewUsernameVariable, NewPasswordVariable]
|
||||
),
|
||||
delete=(
|
||||
"Delete the user account",
|
||||
@@ -732,7 +738,7 @@ class UserManagementData(EndpointData):
|
||||
methods = Methods(
|
||||
put=(
|
||||
"Change the password of the user account",
|
||||
[NewPasswordVariable]
|
||||
[NewUsernameVariable, NewPasswordVariable]
|
||||
),
|
||||
delete=(
|
||||
"Delete the user account",
|
||||
|
||||
Reference in New Issue
Block a user