added basic edit account

- add link in to edit a user in users.html
- change to AccountController
  - update getCreateAccount for change to AccountForm
  - add getEditAccount
- add edit.html
- change to Mapping.kt
  - update AccountForm toAccountRequest to throw exception if password null
  - add Account Response toAccountForm
- change password and passwordConfirm to be null in AccountForm
- add PasswordException
- add getAccount to AccountRegistryService
- add accountRegistryAccount to WebClientCalls.kt
This commit is contained in:
2025-01-27 13:26:31 +01:00
parent 8e65de0350
commit 14e7971f73
8 changed files with 167 additions and 4 deletions

View File

@@ -1,5 +1,6 @@
package ltd.hlaeja.util
import ltd.hlaeja.exception.PasswordException
import ltd.hlaeja.form.AccountForm
import ltd.hlaeja.library.accountRegistry.Account
import ltd.hlaeja.library.accountRegistry.Authentication
@@ -12,7 +13,13 @@ fun SpringAuthentication.toAuthenticationRequest(): Authentication.Request = Aut
fun AccountForm.toAccountRequest(): Account.Request = Account.Request(
username = username,
password = password,
password = password ?: throw PasswordException("Password requirements failed"),
enabled = enabled,
roles = listOf("ROLE_${role.uppercase()}"),
)
fun Account.Response.toAccountForm(): AccountForm = AccountForm(
username = username,
enabled = enabled,
role = roles.first().removePrefix("ROLE_").lowercase()
)