auth0-cli icon indicating copy to clipboard operation
auth0-cli copied to clipboard

Block a user account

Open hexpunk opened this issue 2 years ago • 2 comments

Checklist

Describe the problem you'd like to have solved

I sometimes find myself in a situation where I want to block many users at once. It would be nice to be able to script it in a shell script using the Auth0 cli.

Currently the Auth0 cli provides commands to list and remove blocks on user accounts, but no way to add a block.

Looking at the Auth0 API, it seems like the action I would want would be to set "blocked" to true on the user update endpoint. No equivalent flag is available on the auth0 users update command.

Describe the ideal solution

There should be a way to block a user using the Auth0 cli tool that's equivalent to blocking a user in the management dashboard.

Either an argument in auth0 users update, which would seem to match how this task would be accomplished using the User Management API, or a command like auth0 users blocks add.

Alternatives and current workarounds

As implied earlier, I could use the User Management API with curl or equivalent, but it would be a smoother workflow to use the cli tool that is already authenticated rather than having to set up a token-based way to authenticate.

Additional context

No response

hexpunk avatar Mar 24 '23 19:03 hexpunk

Hey @hexpunk, whilst this isn't supported by the auth0 users update command currently, in the v1 beta you could achieve this using the auth0 api command that allows you to make authenticated requests to the Management API.

So to block a user you would use the following command auth0 api patch "users/<user_id>" --data "{\"blocked\": true }.

ewanharris avatar Mar 31 '23 10:03 ewanharris

@ewanharris Thanks for the tip! I completely overlooked the auth0 api subcommand.

hexpunk avatar Mar 31 '23 13:03 hexpunk

Hello @hexpunk,

We have introduced a new command auth0 users update <user-id> --blocked as part of the release v1.12.0. Please do check it out and closing this issue for now..!

ramya18101 avatar Apr 29 '25 02:04 ramya18101