diff --git a/next-ui/src/colada/mutations/update-user.ts b/next-ui/src/colada/mutations/update-user.ts
index bf3d6c310..389a39c73 100644
--- a/next-ui/src/colada/mutations/update-user.ts
+++ b/next-ui/src/colada/mutations/update-user.ts
@@ -18,3 +18,18 @@ export const useUpdateUser = defineMutation(() => {
},
})
})
+
+export const useUpdateUserPassword = defineMutation(() => {
+ return useMutation({
+ mutation: ({userId, newPassword}: { userId: string, newPassword: string }) =>
+ komgaClient.PATCH('/api/v2/users/{id}/password', {
+ params: {path: {id: userId}},
+ body: {
+ password: newPassword,
+ },
+ }),
+ onError: (error) => {
+ console.log('update user password error', error)
+ },
+ })
+})
diff --git a/next-ui/src/components/dialogs/DialogConfirmEdit.vue b/next-ui/src/components/dialogs/DialogConfirmEdit.vue
index 2de6f9851..7b0504562 100644
--- a/next-ui/src/components/dialogs/DialogConfirmEdit.vue
+++ b/next-ui/src/components/dialogs/DialogConfirmEdit.vue
@@ -10,12 +10,15 @@
@save="close()"
>
-
-
-
+
+
-
-
+
-
-
-
-
-
-
+
+
+
+
+
+
+
@@ -50,6 +52,10 @@ const record = defineModel('record', {required: true})
const formValid = ref(false)
+function submitForm(callback: () => void) {
+ if(formValid.value) callback()
+}
+
export interface Props {
title?: string,
subtitle?: string,
diff --git a/next-ui/src/components/forms/user/FormUserChangePassword.vue b/next-ui/src/components/forms/user/FormUserChangePassword.vue
index ca407e59a..5b81178d2 100644
--- a/next-ui/src/components/forms/user/FormUserChangePassword.vue
+++ b/next-ui/src/components/forms/user/FormUserChangePassword.vue
@@ -1,17 +1,31 @@
-
-
+
+
diff --git a/next-ui/src/pages/server/users.vue b/next-ui/src/pages/server/users.vue
index 3748239a9..f4e1dbbfa 100644
--- a/next-ui/src/pages/server/users.vue
+++ b/next-ui/src/pages/server/users.vue
@@ -61,12 +61,12 @@
refetchUsers())
// Dialogs handling
+// stores the user being actioned upon
const userRecord = ref()
+// stores the ongoing action, so we can handle the action when the dialog is closed with changes
const currentAction = ref()
+// the record passed to the dialog's form's model
+const dialogRecord = ref()
const activator = ref()
const dialogTitle = ref()
+// dynamic component for the dialog's inner form
const dialogComponent = shallowRef()
const {mutate: mutateUser} = useUpdateUser()
+const {mutate: mutateUserPassword} = useUpdateUserPassword()
enum ACTION {
EDIT, DELETE, RESTRICTIONS, PASSWORD
@@ -151,32 +157,41 @@ function showDialog(action: ACTION, user: components["schemas"]["UserDto"]) {
case ACTION.EDIT:
dialogTitle.value = 'Edit Roles'
dialogComponent.value = FormUserRoles
+ dialogRecord.value = user
break;
case ACTION.DELETE:
dialogTitle.value = 'Delete User'
dialogComponent.value = FormUserRoles
+ dialogRecord.value = user
break;
case ACTION.RESTRICTIONS:
dialogTitle.value = 'Edit Restrictions'
dialogComponent.value = FormUserRoles
+ dialogRecord.value = user
break;
case ACTION.PASSWORD:
dialogTitle.value = 'Change Password'
dialogComponent.value = FormUserChangePassword
+ // password change initiated with an empty string
+ dialogRecord.value = ''
}
userRecord.value = user
}
-function handleConfirmation() {
+function handleDialogConfirmation() {
switch (currentAction.value) {
case ACTION.EDIT:
- mutateUser(userRecord.value!)
+ mutateUser(dialogRecord.value as components["schemas"]["UserDto"])
break;
case ACTION.DELETE:
break;
case ACTION.RESTRICTIONS:
break;
case ACTION.PASSWORD:
+ mutateUserPassword({
+ userId: userRecord.value!.id,
+ newPassword: dialogRecord.value as string,
+ })
break;
}
}