Skip to content

Commit

Permalink
Merge pull request #43 from lammertw/fix-resend-confirmation-code-res…
Browse files Browse the repository at this point in the history
…ponse

Fix response of the resend confirmation code request
  • Loading branch information
gaebel authored Jan 12, 2022
2 parents 13d4261 + e337b7a commit 5bf6e03
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ open class IdentityProviderClient(region: String, clientId: String) : IdentityPr

override suspend fun resendConfirmationCode(
username: String
): Result<CodeDeliveryDetails> = request(
): Result<ResendConfirmationCodeResponse> = request(
Request.ResendConfirmationCode,
ResendConfirmationCode(
ClientId = configuration.clientId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ interface IdentityProvider {
/**
* Resends the confirmation (for confirmation of registration) to a specific user in the user pool.
* @param username The username
* @return Result object containing CodeDeliveryDetails on success or an error on failure
* @return Result object containing ResendConfirmationCodeResponse on success or an error on failure
*/
suspend fun resendConfirmationCode(username: String): Result<CodeDeliveryDetails>
suspend fun resendConfirmationCode(username: String): Result<ResendConfirmationCodeResponse>

/**
* Signs in the user with the given parameters
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ data class SignUpResponse(
val UserSub: String
)

@Serializable
data class ResendConfirmationCodeResponse(
val CodeDeliveryDetails: CodeDeliveryDetails
)

@Serializable
data class CodeDeliveryDetails(
val AttributeName: String,
Expand Down
4 changes: 2 additions & 2 deletions src/jsMain/kotlin/IdentityProviderJS.kt
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ class IdentityProviderClientJS(region: String, clientId: String) {
.getOrThrow()
}

fun resendConfirmationCode(username: String): Promise<CodeDeliveryDetailsJS> =
fun resendConfirmationCode(username: String): Promise<ResendConfirmationCodeResponseJS> =
MainScope().promise {
provider.resendConfirmationCode(username)
.getOrThrow().let { it.toJs() }
.getOrThrow().let { ResendConfirmationCodeResponseJS(it.CodeDeliveryDetails.toJs()) }
}

fun signIn(username: String, password: String): Promise<SignInResponseJS> =
Expand Down
3 changes: 3 additions & 0 deletions src/jsMain/kotlin/ResponseJS.kt
Original file line number Diff line number Diff line change
Expand Up @@ -102,3 +102,6 @@ data class MFAOptionsJS(
val AttributeName: String,
val DeliveryMedium: String
)
data class ResendConfirmationCodeResponseJS(
val CodeDeliveryDetails: CodeDeliveryDetailsJS
)

0 comments on commit 5bf6e03

Please sign in to comment.