use of com.amplifyframework.auth.cognito.options.AWSCognitoAuthSignInOptions in project amplify-android by aws-amplify.
the class AWSCognitoAuthPlugin method signIn.
@Override
public void signIn(@Nullable String username, @Nullable String password, @NonNull AuthSignInOptions options, @NonNull final Consumer<AuthSignInResult> onSuccess, @NonNull final Consumer<AuthException> onException) {
final Map<String, String> metadata = new HashMap<>();
AuthFlowType authFlowType = null;
if (options instanceof AWSCognitoAuthSignInOptions) {
metadata.putAll(((AWSCognitoAuthSignInOptions) options).getMetadata());
authFlowType = ((AWSCognitoAuthSignInOptions) options).getAuthFlowType();
}
com.amazonaws.services.cognitoidentityprovider.model.AuthFlowType sdkAuthFlowType = null;
if (authFlowType != null) {
sdkAuthFlowType = com.amazonaws.services.cognitoidentityprovider.model.AuthFlowType.valueOf(authFlowType.name());
}
awsMobileClient.signIn(username, password, metadata, Collections.emptyMap(), sdkAuthFlowType, new Callback<SignInResult>() {
@Override
public void onResult(SignInResult result) {
try {
AuthSignInResult newResult = convertSignInResult(result);
fetchAndSetUserId(() -> onSuccess.accept(newResult));
} catch (AuthException exception) {
onException.accept(exception);
}
}
@Override
public void onError(Exception error) {
onException.accept(CognitoAuthExceptionConverter.lookup(error, "Sign in failed"));
}
});
}
Aggregations