- add messages fragment
- extract error and success message list from edit.html
- extract error message list from create.html
- add messages.html
- update edit account
- update AccountController
- update postEditAccount for validation
- update getEditAccount for roleGroups
- update validation for AccountForm for edit
- add EditGroup
- update Account.Response.toAccountForm()
- update edit.html
- update create account
- update AccountController
- update postCreateAccount for validation
- update getCreateAccount for role group
- add validation to AccountForm
- add PasswordMatchValidator
- add annotation PasswordMatch
- add CreateGroup
- add temporary getRoles() in AccountRegistryService
- update AccountForm.toAccountRequest() in Mapping
- change management.css
- add ::selection
- add Selected Option Styling
- add passwordMatchCheck to management.js
- update create.html
- update user
- add makeLocalTime in management.js
- update users.html
- update Pagination
- add size of items
- rename size to show
- update goodbye.html
- update logout.html
- update login.html
- update welcome.html
- update index.html
- update layout
- update management.css
- update management.js
- update layout.html
29 lines
906 B
Kotlin
29 lines
906 B
Kotlin
package ltd.hlaeja.util
|
|
|
|
import ltd.hlaeja.form.AccountForm
|
|
import ltd.hlaeja.library.accountRegistry.Account
|
|
import ltd.hlaeja.library.accountRegistry.Authentication
|
|
import org.springframework.security.core.Authentication as SpringAuthentication
|
|
|
|
fun SpringAuthentication.toAuthenticationRequest(): Authentication.Request = Authentication.Request(
|
|
principal as String,
|
|
credentials as String,
|
|
)
|
|
|
|
fun AccountForm.toAccountRequest(): Account.Request = Account.Request(
|
|
username = username,
|
|
password = if (password.isNullOrEmpty()) null else password,
|
|
enabled = enabled,
|
|
roles = roles.map { "ROLE_${it.uppercase()}" },
|
|
)
|
|
|
|
fun Account.Response.toAccountForm(): AccountForm = AccountForm(
|
|
username = username,
|
|
enabled = enabled,
|
|
roles = roles.map {
|
|
it.removePrefix("ROLE_")
|
|
.lowercase()
|
|
.replaceFirstChar { char -> char.uppercase() }
|
|
},
|
|
)
|