Skip to content

Commit

Permalink
fix(auth): uses nextStep helper for signInResult on Android (aws-ampl…
Browse files Browse the repository at this point in the history
  • Loading branch information
haverchuck authored Jun 30, 2021
1 parent d3bdb80 commit 5eeca68
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,30 +15,22 @@

package com.amazonaws.amplify.amplify_auth_cognito.types

import com.amazonaws.amplify.amplify_auth_cognito.setNextStep
import com.amplifyframework.auth.result.AuthSignInResult

data class FlutterSignInResult(private val raw: AuthSignInResult) {
val isSignedIn: Boolean = raw.isSignInComplete
val nextStep: Map<String, Any> = setNextStep();
val nextStep: Map<String, Any> = setNextStep(
"signInStep",
raw.nextStep.signInStep.toString(),
raw.nextStep.codeDeliveryDetails,
raw.nextStep.additionalInfo)

private fun setNextStep(): Map<String, Any> {
val res: Map<String, Any> = emptyMap();

return mapOf(
"signInStep" to raw.nextStep.signInStep.toString(),
"additionalInfo" to (raw.nextStep.additionalInfo ?: emptyMap<String, String>()),
"codeDeliveryDetails" to mapOf(
"destination" to (raw.nextStep.codeDeliveryDetails?.destination ?: ""),
"deliveryMedium" to (raw.nextStep.codeDeliveryDetails?.deliveryMedium?.name ?: ""),
"attributeName" to (raw.nextStep.codeDeliveryDetails?.attributeName ?: "")
)
)
}

fun toValueMap(): Map<String, Any> {
return mapOf(
"isSignedIn" to this.isSignedIn,
"nextStep" to this.nextStep
"isSignedIn" to this.isSignedIn,
"nextStep" to this.nextStep
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ func setCodeDeliveryDetails(res: AmplifyOperation<AuthSignInRequest, AuthSignInR
case .success(let signInResult):
if case let .confirmSignInWithSMSMFACode(deliveryDetails, _) = signInResult.nextStep {
if case let .sms(e) = deliveryDetails.destination {
deliveryMap["deliveryMedium"] = "SMS"
deliveryMap["destination"] = e! as String
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import '../types/AuthNextStep.dart';
class AuthNextSignInStep extends AuthNextStep {
String signInStep;
AuthNextSignInStep(
{additionalInfo, required codeDeliveryDetails, required this.signInStep})
{additionalInfo, codeDeliveryDetails, required this.signInStep})
: super(
additionalInfo: additionalInfo,
codeDeliveryDetails: codeDeliveryDetails);
Expand Down

0 comments on commit 5eeca68

Please sign in to comment.