added basic edit save account
- changes to AccountController - added postEditAccount - change postCreateAccount to use lambda - added success message to edit.html - added lambda to deal with password to toAccountRequest in Mapping.kt - added updateAccount to AccountRegistryService - added accountRegistryUpdate to WebClientCalls.kt - added NoChangeException - added NotFoundException
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
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
|
||||
@@ -11,9 +10,9 @@ fun SpringAuthentication.toAuthenticationRequest(): Authentication.Request = Aut
|
||||
credentials as String,
|
||||
)
|
||||
|
||||
fun AccountForm.toAccountRequest(): Account.Request = Account.Request(
|
||||
fun AccountForm.toAccountRequest(operation: (CharSequence?) -> CharSequence?): Account.Request = Account.Request(
|
||||
username = username,
|
||||
password = password ?: throw PasswordException("Password requirements failed"),
|
||||
password = operation(password),
|
||||
enabled = enabled,
|
||||
roles = listOf("ROLE_${role.uppercase()}"),
|
||||
)
|
||||
@@ -21,5 +20,5 @@ fun AccountForm.toAccountRequest(): Account.Request = Account.Request(
|
||||
fun Account.Response.toAccountForm(): AccountForm = AccountForm(
|
||||
username = username,
|
||||
enabled = enabled,
|
||||
role = roles.first().removePrefix("ROLE_").lowercase()
|
||||
role = roles.first().removePrefix("ROLE_").lowercase(),
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user