public async Task <RequestResult> DeleteUnConfirmedUser(string username, string password)
        {
            RequestResult result = new RequestResult();

            try
            {
                CognitoUserPool userPool = new CognitoUserPool(this.POOL_ID, this.CLIENTAPP_ID, provider);
                Amazon.Extensions.CognitoAuthentication.CognitoUser user = new Amazon.Extensions.CognitoAuthentication.CognitoUser(username, this.CLIENTAPP_ID, userPool, provider);


                AdminDeleteUserRequest req = new AdminDeleteUserRequest()
                {
                    Username = username, UserPoolId = POOL_ID
                };
                AdminDeleteUserResponse response = await provider.AdminDeleteUserAsync(req);


                if (response.HttpStatusCode == HttpStatusCode.OK)
                {
                    result.Status  = true;
                    result.Message = "Deleted Successfully";
                }
            }
            catch (Exception ex)
            {
                result.Status  = false;
                result.Message = ex.Message;
            }

            return(result);
        }
Example #2
0
        public bool DeleteUser(string email)
        {
            AdminDeleteUserRequest adminDeleteUserRequest = new AdminDeleteUserRequest
            {
                Username   = email,
                UserPoolId = _connectionInfo.UserPoolId
            };

            try
            {
                var response = _provider.AdminDeleteUserAsync(adminDeleteUserRequest).Result;
                if (response.HttpStatusCode == HttpStatusCode.OK)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch (AggregateException e)
            {
                bool response = false;  // Let anything we can't handle stop the application.
                e.Handle((x) =>
                {
                    if (x is NotAuthorizedException)  // This we know how to handle.
                    {
                        LoggingHandler.LogError("Authentication Gateway:  Invalid credentials provided.");
                        response = false;
                    }
                    if (x is UserNotFoundException)  // This we know how to handle.
                    {
                        LoggingHandler.LogWarning("Authentication Gateway:  User not found.");
                        response = true;
                    }
                    return(response);
                });
                return(response);
            }
            catch (Exception e)
            {
                LoggingHandler.LogError(e.Message);
                LoggingHandler.LogError(e.StackTrace);
                throw;
            }
        }
        async Task <bool> ILoginProvider.DeleteLogin(string email)
        {
            var request = new AdminDeleteUserRequest
            {
                Username   = email,
                UserPoolId = _settngs.UserPoolId
            };

            try
            {
                await _client.AdminDeleteUserAsync(request);

                return(true);
            }
            catch (UserNotFoundException)
            {
                _logger.LogInformation($"Failed to delete loginId {email} due to Exception");
                return(false);
            }
        }
 public void AdminDeleteUserAsync(AdminDeleteUserRequest request, AmazonServiceCallback <AdminDeleteUserRequest, AdminDeleteUserResponse> callback, AsyncOptions options = null)
 {
     throw new System.NotImplementedException();
 }