public async Task SignUpUserConfirmation(ISignupConfirmModelUser confirmation) { try { ConfirmSignUpRequest confirmRequest = new ConfirmSignUpRequest() { Username = confirmation.Username, ConfirmationCode = confirmation.ConfirmationCode, ClientId = GetClientId(), }; AmazonCognitoIdentityProviderClient client = GetAmazonCognitoIdentity(); ConfirmSignUpResponse confirmResult = await client.ConfirmSignUpAsync(confirmRequest); } catch (CodeMismatchException e) { throw new WebApiException(System.Net.HttpStatusCode.Forbidden, e.Message); } catch (ExpiredCodeException e) { throw new WebApiException(System.Net.HttpStatusCode.Forbidden, e.Message); } catch (Exception e) { throw new WebApiException(System.Net.HttpStatusCode.InternalServerError, e.Message); } }
public async Task <RequestResult> VerifyAccessCode(User user) { RequestResult result = new RequestResult(); ConfirmSignUpRequest confirmSignUpRequest = new ConfirmSignUpRequest(); confirmSignUpRequest.Username = user.Email; confirmSignUpRequest.ConfirmationCode = user.Code; confirmSignUpRequest.ClientId = CLIENTAPP_ID; try { ConfirmSignUpResponse confirmSignUpResult = await provider.ConfirmSignUpAsync(confirmSignUpRequest); Console.WriteLine(confirmSignUpResult.ToString()); result.Status = true; result.Message = "User Verified Successfully. Please Sign In."; } catch (Exception ex) { result.Status = false; result.Message = ex.Message; Console.WriteLine(ex); } return(result); }
/// <summary> /// A simple function that takes a string and does a ToUpper /// </summary> /// <param name="input"></param> /// <param name="context"></param> /// <returns></returns> public async Task <string> FunctionHandler(ConfirmSignUpRequest request, ILambdaContext context) { CognitoService helper = new CognitoService(); await helper.ConfirmSignUp(request); return(request.ToString <ConfirmSignUpRequest>()); }
public static void Main() { ConfirmSignUpRequest request = new ConfirmSignUpRequest(); Console.WriteLine(request.ToString <ConfirmSignUpRequest>()); Console.ReadLine(); //client = new AmazonS3Client(bucketRegion); //ReadObjectDataAsync().Wait(); }
public override async Task <Empty> ConfirmSignUp(ConfirmSignUpRequest request, ServerCallContext context) { var command = new ConfirmIdentityCommand( request.Id.ToAccountId(), new ObjectId(request.Confirm.Id), request.Confirm.Code ); await _mediator.Send(command); return(new Empty()); }
public async Task Confirm() { try { if (!connectivity.IsConnected) { await View.DisplayAlert("Internet required", "To sign up the app requires internet connection.", "Ok"); return; } ConfirmSignUpResponse response; using (WorkingScope.Enter()) { (string deviceId, string deviceName) = GetDeviceInfo(); var request = new ConfirmSignUpRequest { RequestId = requestId, DeviceId = deviceId, DeviceName = deviceName, ConfirmationCode = ConfirmationCode.Value, }; response = await accountService.ConfirmSignup(request); } if (response.Success) { await dataFlow.UpdateUserId(response.UserId); await dataFlow.UpdateAccessCode(response.AccessCode); var setPinViewModel = createSetPinViewModel(); viewService.SetCurrentPage(setPinViewModel); } else { await View.DisplayAlert("Invalid Code", response.Error, "Ok"); } } catch (Exception ex) { Crashes.TrackError(ex, new Dictionary <string, string> { { "page", "confirmation code entry" }, { "operation", nameof(Confirm) } }); await View.DisplayAlert("Error", ex.Message, "Ok"); } }
public async Task <IActionResult> Confirm(User user) { var cognito = new AmazonCognitoIdentityProviderClient(_region); ConfirmSignUpRequest confirmRequest = new ConfirmSignUpRequest { Username = user.Username, ClientId = _appConfig.Value.AppClientId, ConfirmationCode = user.ConfirmationCode, //SecretHash = (username, configuration["cognito:clientId"], configuration["cognito:secretKey"]) }; await cognito.ConfirmSignUpAsync(confirmRequest); return(new OkObjectResult("Account has been confirmed")); }
private ConfirmSignUpRequest CreateConfirmSignUpRequest(string confirmationCode, bool forcedAliasCreation) { ConfirmSignUpRequest confirmRequest = new ConfirmSignUpRequest() { ClientId = ClientID, Username = Username, ForceAliasCreation = forcedAliasCreation, ConfirmationCode = confirmationCode }; if (!string.IsNullOrEmpty(SecretHash)) { confirmRequest.SecretHash = SecretHash; } return(confirmRequest); }
private async void ConfirmButton_Click(object sender, RoutedEventArgs e) { try { ConfirmSignUpRequest confirmRequest = new ConfirmSignUpRequest() { Username = UserNameTextBox.Text, ClientId = _clientId, ConfirmationCode = ConfirmationTextBox.Text }; var confirmResult = await _client.ConfirmSignUpAsync(confirmRequest); } catch (Exception ex) { string message = ex.Message; await new MessageDialog(message, "Sign Up Error").ShowAsync(); } }
private async void btnConfirm_Click(object sender, RoutedEventArgs e) { try { Amazon.CognitoIdentityProvider.Model.ConfirmSignUpRequest confirmSignUpRequest = new ConfirmSignUpRequest() { Username = txtEmail.Text, ClientId = _clientId, ConfirmationCode = txtConfirm.Text }; var confirmResult = await _client.ConfirmSignUpAsync(confirmSignUpRequest); } catch (Exception ex) { string message = ex.Message; var msgBox = new MessageDialog(message, "Sign Up Error"); await msgBox.ShowAsync(); } }
public async Task VerifyAccessCode(string username, string code) { try { AmazonCognitoIdentityProviderClient provider = new AmazonCognitoIdentityProviderClient(new Amazon.Runtime.AnonymousAWSCredentials(), RegionEndpoint.EUCentral1); ConfirmSignUpRequest confirmSignUpRequest = new ConfirmSignUpRequest(); confirmSignUpRequest.Username = username; confirmSignUpRequest.ConfirmationCode = code; confirmSignUpRequest.ClientId = CLIENTAPP_ID; await provider.ConfirmSignUpAsync(confirmSignUpRequest); UserInfo.Verified = true; } catch (Exception ex) { Console.WriteLine("VerifyAccessCode ERROR: " + ex.Message); throw ex; } }
/// <summary> /// Verify the access code to confirm signup when force password change is not imposed. /// </summary> /// <param name="username"></param> /// <param name="code"></param> /// <returns></returns> public async Task <bool> ConfirmSignUp(Real.ConfirmSignUpRequest request) { AmazonCognitoIdentityProviderClient provider = new AmazonCognitoIdentityProviderClient(new Amazon.Runtime.AnonymousAWSCredentials()); ConfirmSignUpRequest confirmSignUpRequest = new ConfirmSignUpRequest(); confirmSignUpRequest.Username = request.Username; confirmSignUpRequest.ConfirmationCode = request.TempCode; confirmSignUpRequest.ClientId = CLIENTAPP_ID; try { ConfirmSignUpResponse confirmSignUpResult = await provider.ConfirmSignUpAsync(confirmSignUpRequest); Console.WriteLine(confirmSignUpResult.ToString()); } catch (Exception ex) { ThrowCustomException(CognitoActionType.UserConfirmSignUp, ExceptionConstants.InternalServerErrorException, ex.StackTrace, ex.Message); } return(true); }
public async Task <IActionResult> Confirm(UserToConfirmRequest userToConfirmRequest) { try { ConfirmSignUpRequest confirmRequest = new ConfirmSignUpRequest() { Username = userToConfirmRequest.Email, ClientId = _config.GetSection("AWS").GetSection("UserPoolClientId").Value, ConfirmationCode = userToConfirmRequest.Code }; await _cognitoIdentityProvider.ConfirmSignUpAsync(confirmRequest); return(Ok(new CommonResponse(ErrorCodes.SUCCESS))); } catch (AmazonServiceException e) { return(BadRequest(new CommonResponse(ErrorCodes.ERROR, e.Message))); } }
internal async Task <bool> VerifyAccessCode(string username, string code) { AmazonCognitoIdentityProviderClient provider = new AmazonCognitoIdentityProviderClient(new AnonymousAWSCredentials(), REGION); ConfirmSignUpRequest confirmSignUpRequest = new ConfirmSignUpRequest() { Username = username, ConfirmationCode = code, ClientId = CLIENT_ID }; ConfirmSignUpResponse result = provider.ConfirmSignUp(confirmSignUpRequest); if (result != null) { return(true); } else { return(false); } }
internal async Task <bool> VerifyAccessCode(string username, string code) { AmazonCognitoIdentityProviderClient provider = new AmazonCognitoIdentityProviderClient(new Amazon.Runtime.AnonymousAWSCredentials()); ConfirmSignUpRequest confirmSignUpRequest = new ConfirmSignUpRequest(); confirmSignUpRequest.Username = username; confirmSignUpRequest.ConfirmationCode = code; confirmSignUpRequest.ClientId = CLIENTAPP_ID; try { ConfirmSignUpResponse confirmSignUpResult = provider.ConfirmSignUp(confirmSignUpRequest); Console.WriteLine(confirmSignUpResult.ToString()); } catch (Exception ex) { Console.WriteLine(ex); return(false); } return(true); }
public override async Task <IdentityResult> ConfirmEmailAsync(string username, string code) { // Register the user using Cognito var confirmSignUpRequest = new ConfirmSignUpRequest { ClientId = _clientId, ConfirmationCode = code, Username = username }; try { var result = await _client.ConfirmSignUpAsync(confirmSignUpRequest); return(IdentityResult.Success); } catch (Exception e) { return(IdentityResult.Failed(e.Message)); } }
public async Task <HttpResponseMessage> ConfirmUserAsync(AwsCognitoUser user) { if (!await _cognitoAdapterHelper.UserExists(user)) { return(new HttpResponseMessage(HttpStatusCode.NotFound)); } if (await _cognitoAdapterHelper.UserIsConfirmed(user)) { return(new HttpResponseMessage(HttpStatusCode.Conflict)); } var confirmSignupRequest = new ConfirmSignUpRequest { Username = user.UserName, ConfirmationCode = user.ConfirmationCode, ClientId = _clientId }; await _awsCognitoClient.ConfirmSignUpAsync(confirmSignupRequest); return(new HttpResponseMessage(HttpStatusCode.OK)); }
public async Task <IActionResult> Confirm_Post(ConfirmModel model) { if (ModelState.IsValid) { var user = await _userManager.FindByEmailAsync(model.Email).ConfigureAwait(false); if (user == null) { ModelState.AddModelError("NotFound", "A user with the given email address was not found"); return(View(model)); } ConfirmSignUpRequest confirmRequest = new ConfirmSignUpRequest() { Username = model.Email, ConfirmationCode = model.Code }; await _signInManager.SignInAsync(user, isPersistent : false).ConfigureAwait(false); //var result = await (_userManager as CognitoUserManager<CognitoUser>).ConfirmEmailAsync(user, model.Code).ConfigureAwait(false); var result = await _userManager.ConfirmEmailAsync(user, model.Code).ConfigureAwait(false); if (result.Succeeded) { return(RedirectToAction("Index", "Home")); } foreach (var item in result.Errors) { ModelState.AddModelError(item.Code, item.Description); } return(View((model))); } return(View("Confirm", model)); }
public override async Task Start(string _postJson, IDynamoDBContext _dynamoDBContext) { await base.Start(_postJson, _dynamoDBContext); User user = JsonConvert.DeserializeObject <User>(_postJson); var signUpRequest = new ConfirmSignUpRequest { ClientId = ApiDefine.CognitoClientId, ConfirmationCode = user.Password, Username = user.Name }; var client = new AmazonCognitoIdentityProviderClient(ApiDefine.Credentials, RegionEndpoint.USWest2); var result = await client.ConfirmSignUpAsync(signUpRequest); JsPath = "cognito/confirm.js"; string json = JsonConvert.SerializeObject(result); await loadJs(); ExecJs = ExecJs.Replace("JSON", json.Replace("\"", "\\\"")); }
public bool ConfirmSignup(UserConfirmRequest confirmRequest) { ConfirmSignUpRequest signUpRequest = new ConfirmSignUpRequest { ClientId = _connectionInfo.ClientId, Username = confirmRequest.Email, ConfirmationCode = confirmRequest.Code }; try { ConfirmSignUpResponse response = _provider.ConfirmSignUpAsync(signUpRequest).Result; return(response.HttpStatusCode == HttpStatusCode.OK); } catch (AggregateException e) { if (e.InnerException != null) { throw new UseCaseException() { UserErrorMessage = e.Message } } ; throw new UseCaseException() { UserErrorMessage = e.Message, DevErrorMessage = e.ToString() }; } catch (Exception e) { LoggingHandler.LogError(e.Message); LoggingHandler.LogError(e.StackTrace); throw; } }
public async Task <Tuple <int, string> > ConfirmSignupAsync(string username, string code) { try { ConfirmSignUpRequest confirmRequest = new ConfirmSignUpRequest() { Username = username, ClientId = Constants.POOL_CLIENT_ID, ConfirmationCode = code }; var confirmResult = await client.ConfirmSignUpAsync(confirmRequest); if (confirmResult.HttpStatusCode == HttpStatusCode.OK) { return(Tuple.Create <int, string>(1, "Confirmation request successfully!")); } } catch (Exception e) { return(Tuple.Create <int, string>(0, e.Message)); } return(Tuple.Create <int, string>(-1, "Unable to confirm request!")); }
public async Task <ConfirmSignUpResponse> ConfirmSignUpAsync(string username, string confirmationCode) { var client = new AmazonCognitoIdentityProviderClient(null, this.RegionEndpoint); ConfirmSignUpRequest confirmSignUpRequest = new ConfirmSignUpRequest(); confirmSignUpRequest.Username = username; confirmSignUpRequest.ConfirmationCode = confirmationCode; confirmSignUpRequest.ClientId = this.ClientId; if (!string.IsNullOrEmpty(this.ClientSecret)) { confirmSignUpRequest.SecretHash = CalculateSecretHash(this.ClientId, this.ClientSecret, username); } try { ConfirmSignUpResponse confirmSignUpResult = await client.ConfirmSignUpAsync(confirmSignUpRequest); return(confirmSignUpResult); } catch (Exception ex) { throw; } }
public async Task <ConfirmSignUpResponse> ConfirmSignup(ConfirmSignUpRequest request) => await Client.Post <ConfirmSignUpRequest, ConfirmSignUpResponse>("account/confirmsignup", request);
/// <summary> /// Confirms the sign up of the associated user using the provided confirmation code /// using an asynchronous call /// </summary> /// <param name="confirmationCode">Confirmation code sent to user via email or SMS</param> /// <param name="forcedAliasCreation">Boolean specifying whether forced alias creation is desired</param> public void ConfirmSignUpAsync(string confirmationCode, bool forcedAliasCreation, AsyncCallback callback = null) { ConfirmSignUpRequest confirmRequest = CreateConfirmSignUpRequest(confirmationCode, forcedAliasCreation); Provider.ConfirmSignUpAsync(confirmRequest, r => callback?.Invoke(new AsyncResult(r.Exception))); }
public void ConfirmSignUpAsync(ConfirmSignUpRequest request, AmazonServiceCallback <ConfirmSignUpRequest, ConfirmSignUpResponse> callback, AsyncOptions options = null) { throw new System.NotImplementedException(); }
/// <summary> /// Confirms the sign up of the associated user using the provided confirmation code /// using an asynchronous call /// </summary> /// <param name="confirmationCode">Confirmation code sent to user via email or SMS</param> /// <param name="forcedAliasCreation">Boolean specifying whether forced alias creation is desired</param> public virtual Task ConfirmSignUpAsync(string confirmationCode, bool forcedAliasCreation) { ConfirmSignUpRequest confirmRequest = CreateConfirmSignUpRequest(confirmationCode, forcedAliasCreation); return(Provider.ConfirmSignUpAsync(confirmRequest)); }