feat: enable password update
All checks were successful
Deploy Miniplan / build (push) Successful in 2m21s
All checks were successful
Deploy Miniplan / build (push) Successful in 2m21s
This commit is contained in:
@@ -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<JWTPrincipal>()!!
|
||||
val request = call.receive<AuthenticationUpdateRequest>()
|
||||
|
||||
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))
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user