diff --git a/src/main/kotlin/com/vauthenticator/server/account/Account.kt b/src/main/kotlin/com/vauthenticator/server/account/Account.kt index 163c7c58..513bc840 100644 --- a/src/main/kotlin/com/vauthenticator/server/account/Account.kt +++ b/src/main/kotlin/com/vauthenticator/server/account/Account.kt @@ -27,7 +27,7 @@ data class Account( val birthDate: Optional, val phone: Optional, val locale: Optional, - val mandatoryActions: List = listOf(NO_ACTION) + val mandatoryAction: AccountMandatoryAction =NO_ACTION ) { val sub: String get() = email.toSha256() diff --git a/src/main/kotlin/com/vauthenticator/server/account/repository/DynamoAccountConverter.kt b/src/main/kotlin/com/vauthenticator/server/account/repository/DynamoAccountConverter.kt index a6a8a0d9..4bc7bf76 100644 --- a/src/main/kotlin/com/vauthenticator/server/account/repository/DynamoAccountConverter.kt +++ b/src/main/kotlin/com/vauthenticator/server/account/repository/DynamoAccountConverter.kt @@ -1,7 +1,10 @@ package com.vauthenticator.server.account.repository import com.vauthenticator.server.account.* -import com.vauthenticator.server.extentions.* +import com.vauthenticator.server.extentions.asDynamoAttribute +import com.vauthenticator.server.extentions.valueAsBoolFor +import com.vauthenticator.server.extentions.valueAsStringFor +import com.vauthenticator.server.extentions.valueAsStringSetFor import software.amazon.awssdk.services.dynamodb.model.AttributeValue object DynamoAccountConverter { @@ -22,8 +25,7 @@ object DynamoAccountConverter { birthDate = Date.isoDateFor(dynamoPayload.valueAsStringFor("birthDate")), phone = Phone.phoneFor(dynamoPayload.valueAsStringFor("phone")), locale = UserLocale.localeFrom(dynamoPayload.valueAsStringFor("locale")), - mandatoryActions = dynamoPayload.valuesAsListOfStringFor("mandatory_actions") - .map(AccountMandatoryAction::valueOf) + mandatoryAction = AccountMandatoryAction.valueOf(dynamoPayload.valueAsStringFor("mandatory_action")) ) fun fromDomainToDynamo(account: Account) = @@ -42,6 +44,6 @@ object DynamoAccountConverter { "birthDate" to account.birthDate.map { it.asDynamoAttribute() }.orElse("".asDynamoAttribute()), "phone" to account.phone.map { it.asDynamoAttribute() }.orElse("".asDynamoAttribute()), "locale" to account.locale.map { it.formattedLocale().asDynamoAttribute() }.orElse("".asDynamoAttribute()), - "mandatory_actions" to account.mandatoryActions.map { it.name }.toSet().asDynamoAttribute() + "mandatory_action" to account.mandatoryAction.let { it.name }.asDynamoAttribute() ) } \ No newline at end of file diff --git a/src/test/kotlin/com/vauthenticator/server/account/AccountTestFixture.kt b/src/test/kotlin/com/vauthenticator/server/account/AccountTestFixture.kt index ca46ce23..3f178fbd 100644 --- a/src/test/kotlin/com/vauthenticator/server/account/AccountTestFixture.kt +++ b/src/test/kotlin/com/vauthenticator/server/account/AccountTestFixture.kt @@ -17,20 +17,8 @@ object AccountTestFixture { birthDate = Date.empty(), phone = Phone.empty(), locale = UserLocale.empty(), - mandatoryActions = listOf(AccountMandatoryAction.NO_ACTION) + mandatoryAction = AccountMandatoryAction.NO_ACTION ) - fun anAccount(roles: Set) = Account( - enabled = true, - username = EMAIL, - password = "secret", - authorities = roles.map { it.name }.toSet(), - email = EMAIL, - firstName = "A First Name", - lastName = "A Last Name", - birthDate = Date.empty(), - phone = Phone.empty(), - locale = UserLocale.empty(), - mandatoryActions = listOf(AccountMandatoryAction.NO_ACTION) - ) + fun anAccount(roles: Set) = anAccount().copy(authorities = roles.map { it.name }.toSet()) } \ No newline at end of file