public virtual async Task <AuthEventEnum> ResendCodeAsync() { if (CurrentChallenge != AuthChallengeEnum.Code) { return(AuthEventEnum.Alert_InvalidCallToResendAsyncCode); } try { switch (CurrentAuthProcess) { case AuthProcessEnum.UpdatingEmail: // We need to re-submit the email change request for Amazon to resend the code if (!IsSignedIn) { return(AuthEventEnum.Alert_NeedToBeSignedIn); } //// Get the current values on the server. //// This step may throw an exception in RefreshUserDetailsAsync. There seems to be //// no way to recover from this other than retry or abandon the process. Let the //// calling class figure out what is right for their usecase. //AuthEventEnum refreshUserDetailsResult = await RefreshUserDetailsAsync().ConfigureAwait(false); //if (refreshUserDetailsResult != AuthEventEnum.Alert_RefreshUserDetailsDone) // return AuthEventEnum.Alert_CantRetrieveUserDetails; //// make sure the values are different //if (this.email.Equals(newEmail)) //todo - check //{ // return AuthEventEnum.Alert_EmailAddressIsTheSame; //} //// Update the user email on the server //// This may throw an exception in the UpdateAttributesAsync call. //var attributes = new Dictionary<string, string>() { { "email", newEmail } }; //// Cognito sends a auth code when the Email attribute is changed //await CognitoUser.UpdateAttributesAsync(attributes).ConfigureAwait(false); await CognitoUser.GetAttributeVerificationCodeAsync("email").ConfigureAwait(false); return(AuthEventEnum.VerificationCodeSent); case AuthProcessEnum.ResettingPassword: // we need to issue the ForgotPassword again to resend code CognitoUser user = new CognitoUser(login, clientId, userPool, providerClient); await user.ForgotPasswordAsync().ConfigureAwait(false); return(AuthEventEnum.AuthChallenge); case AuthProcessEnum.SigningUp: _ = await providerClient.ResendConfirmationCodeAsync( new ResendConfirmationCodeRequest { ClientId = clientId, Username = login }).ConfigureAwait(false); return(AuthEventEnum.AuthChallenge); default: return(AuthEventEnum.Alert_InvalidCallToResendAsyncCode); } } catch (Exception e) { Debug.WriteLine($"SignUp() threw an exception {e}"); return(AuthEventEnum.Alert_Unknown); } }