From b8816d482c3be5201f87932402f2a79f82c03ad5 Mon Sep 17 00:00:00 2001 From: Leo Vasanko Date: Tue, 30 Sep 2025 18:31:20 -0600 Subject: [PATCH] Fix admin UI password reset and user deletion functions. --- cista/auth.py | 12 +++++++++ .../src/components/UserManagementModal.vue | 25 +++++++++++++++---- 2 files changed, 32 insertions(+), 5 deletions(-) diff --git a/cista/auth.py b/cista/auth.py index 7a272ec..2781186 100644 --- a/cista/auth.py +++ b/cista/auth.py @@ -271,6 +271,18 @@ async def update_user(request, username): return json(response) +@bp.delete("/users/") +async def delete_user(request, username): + verify(request, privileged=True) + if username not in config.config.users: + raise BadRequest("User does not exist") + try: + config.del_user(username) + except Exception as e: + raise BadRequest(str(e)) from e + return json({"message": f"User {username} deleted"}) + + @bp.put("/config/public") async def update_public(request): verify(request, privileged=True) diff --git a/frontend/src/components/UserManagementModal.vue b/frontend/src/components/UserManagementModal.vue index 4cc1190..a86507b 100644 --- a/frontend/src/components/UserManagementModal.vue +++ b/frontend/src/components/UserManagementModal.vue @@ -14,9 +14,9 @@

Users

-
+
{{ success }} - +
@@ -70,6 +70,7 @@ const loading = ref(true) const users = ref([]) const error = ref('') const success = ref('') +const copyButtonText = ref('📋') const serverSettings = reactive({ public: false }) @@ -170,11 +171,25 @@ const deleteUserAction = async (username: string) => { } } -const copySuccess = async () => { - const passwordMatch = success.value.match(/Password: (.+)/) +const copySuccess = async (isButtonClick: boolean = false) => { + const passwordMatch = success.value.match(/(?:Password|New password): (.+)/) if (passwordMatch) { await navigator.clipboard.writeText(passwordMatch[1]) - // Maybe flash or something, but for now just copy + if (isButtonClick) { + // Show "Copied!" indication on button + copyButtonText.value = '✅ Copied!' + // Hide password and button immediately after copying + const baseMessage = success.value.replace(/(?:Password|New password): .+/, 'Password copied to clipboard!') + success.value = baseMessage + // Hide the entire message after 3 seconds + setTimeout(() => { + success.value = '' + copyButtonText.value = '📋' + }, 3000) + } else { + // Just hide the message when clicking elsewhere + success.value = '' + } } }