diff --git a/private/minis-backend/src/main/kotlin/de/walamana/views/AuthenticationView.kt b/private/minis-backend/src/main/kotlin/de/walamana/views/AuthenticationView.kt index 766ae76..8a5f1ee 100644 --- a/private/minis-backend/src/main/kotlin/de/walamana/views/AuthenticationView.kt +++ b/private/minis-backend/src/main/kotlin/de/walamana/views/AuthenticationView.kt @@ -34,6 +34,7 @@ data class AuthenticationResult( @Serializable data class AuthenticationUpdateRequest( + val username: String?, val newPassword: String ) @@ -70,7 +71,11 @@ fun Route.configureAuthenticationRoutes() { val principal = call.principal()!! val request = call.receive() - Security.setPassword(principal.payload.username(), request.newPassword) + val username = if(request.username != null && principal.payload.username() == "admin") { + request.username + } else principal.payload.username() + + Security.setPassword(username, request.newPassword) call.respond(hashMapOf("success" to true)) } @@ -92,8 +97,6 @@ fun Route.configureAuthenticationRoutes() { call.respond(hashMapOf("password" to newPassword)) - - } } } diff --git a/public/src/components/dialog/CreateMinistrantDialog.vue b/public/src/components/dialog/CreateMinistrantDialog.vue index cec3f23..f6f80d3 100644 --- a/public/src/components/dialog/CreateMinistrantDialog.vue +++ b/public/src/components/dialog/CreateMinistrantDialog.vue @@ -7,6 +7,7 @@ import {ref, toRaw} from "vue"; import {onKeyPress} from "@/composables/enter"; import {API} from "@/services/api"; import {Dialogs} from "@/services/DialogService"; +import UpdatePasswordDialog from "@/components/dialog/UpdatePasswordDialog.vue"; interface CreateMinistrantDialogProps extends DialogControls { onCreate: (any) => (Promise | undefined), onDelete: (id) => (Promise | undefined), @@ -62,6 +63,23 @@ async function resetPassword(username: string) { console.log(result) } +async function updatePassword(username: string) { + Dialogs.createDialog( + UpdatePasswordDialog, + { + onDismiss(){}, + onNegative(){}, + onPositive(){}, + }, + { + async onUpdated(newPassword: string){ + await API.updatePassword(username, newPassword) + }, + username + } + ) +} +