mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-02-25 18:55:31 -06:00
Add --yes option for skipping the confirmation prompt while deleting the user via CLI for scripting purpose. #7204
This commit is contained in:
parent
96ed38292f
commit
6adae46a4c
@ -187,11 +187,12 @@ Delete User
|
|||||||
***********
|
***********
|
||||||
|
|
||||||
To delete the user, invoke ``setup.py`` with ``delete-user`` command line option, followed by
|
To delete the user, invoke ``setup.py`` with ``delete-user`` command line option, followed by
|
||||||
username and auth_source. For Internal users, email adress will be used instead of username.
|
username and auth_source. For Internal users, email adress will be used instead of username. the option ``--yes`` is available to skip the confirmation prompt before deleting the user.
|
||||||
|
|
||||||
.. code-block:: bash
|
.. code-block:: bash
|
||||||
|
|
||||||
/path/to/python /path/to/setup.py delete-user user1@gmail.com --auth-source internal
|
/path/to/python /path/to/setup.py delete-user user1@gmail.com --auth-source internal
|
||||||
|
/path/to/python /path/to/setup.py delete-user user2@gmail.com --auth-source internal --yes
|
||||||
/path/to/python /path/to/setup.py delete-user ldapuser --auth-source ldap
|
/path/to/python /path/to/setup.py delete-user ldapuser --auth-source ldap
|
||||||
|
|
||||||
|
|
||||||
|
12
web/setup.py
12
web/setup.py
@ -180,11 +180,15 @@ class ManageUsers:
|
|||||||
ManageUsers.create_user(data, console, json)
|
ManageUsers.create_user(data, console, json)
|
||||||
|
|
||||||
@app.command()
|
@app.command()
|
||||||
def delete_user(username: str, auth_source: AuthType = AuthType.internal):
|
def delete_user(username: str,
|
||||||
|
auth_source: AuthType = AuthType.internal,
|
||||||
|
auto_confirm: Annotated[Optional[bool],
|
||||||
|
typer.Option(
|
||||||
|
"--yes")] = False
|
||||||
|
):
|
||||||
"""Delete the user. """
|
"""Delete the user. """
|
||||||
delete = typer.confirm("Are you sure you want to delete it?")
|
confirm_msg = "Are you sure you want to delete it?"
|
||||||
|
if auto_confirm or typer.confirm(confirm_msg):
|
||||||
if delete:
|
|
||||||
app = create_app(config.APP_NAME + '-cli')
|
app = create_app(config.APP_NAME + '-cli')
|
||||||
with app.test_request_context():
|
with app.test_request_context():
|
||||||
uid = ManageUsers.get_user(username=username,
|
uid = ManageUsers.get_user(username=username,
|
||||||
|
Loading…
Reference in New Issue
Block a user