Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Delete All Authenticators API for Users #375

Merged
merged 2 commits into from
Aug 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions lib/auth0/api/v2/users.rb
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,15 @@ def patch_user(user_id, body)
end
alias update_user patch_user

# Delete all authenticators
# @see https://auth0.com/docs/api/management/v2#!/Users/delete_authenticators
# @param user_id [string] The user_id of the user to delete all authenticators
def delete_user_authenticators(user_id)
raise Auth0::MissingUserId, 'Must supply a valid user_id' if user_id.to_s.empty?
path = "#{users_path}/#{user_id}/authenticators"
delete(path)
end

# Delete a user's multifactor provider
# @see https://auth0.com/docs/api/v2#!/Users/delete_multifactor_by_provider
# @param user_id [string] The user_id of the user to delete the multifactor provider from.
Expand Down
15 changes: 15 additions & 0 deletions spec/lib/auth0/api/v2/users_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,21 @@
end
end

context '.delete_user_authenticators' do
it 'is expected to respond to a delete_user_authenticators method' do
expect(@instance).to respond_to(:delete_user_authenticators)
end

it 'is expected to delete /api/v2/users/userId/authenticators' do
expect(@instance).to receive(:delete).with('/api/v2/users/USER_ID/authenticators')
@instance.delete_user_authenticators('USER_ID')
end

it 'is expected to raise an exception when the user ID is empty' do
expect { @instance.delete_user_authenticators(nil) }.to raise_exception(Auth0::MissingUserId)
end
end

context '.delete_user_provider' do
it 'is expected to respond to a delete_user_provider method' do
expect(@instance).to respond_to(:delete_user_provider)
Expand Down