Functionality to remove users from AWS User Pool #62
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR is a continuation of e-mission/e-mission-docs#1008
Copying the following from comment in #45:
I added functionality to remove users who are not in the config file, but are already in the user pool. Previously, I created the
user_already_exists
function:this function takes
users
, which is a list of dictionaries containing info on each user in the pool, and searches for a string matching the desired email.For the new use case, I modified it a bit to create
get_users
:This function is called early on in the program, and gives us the
users
variable:users = get_users(pool_id, cognito_client)
Next, each dictionary in
users
is looped over, and the email is isolated asuser_email
.If the
user_email
is not in theemails
list that was pulled from the config file, another new function namedremove_user
is called:I tested this by adding myself to the pool:
Then trying to re-add myself AND another new email,
And finally, removing my first email from the config to see what happens:
I checked the user pool, and my email1@nrel.gov was indeed removed from the pool! I decided to try and follow the welcome email to log in with my removed email, just to see what would happen. I got the following message: