Re-enable cli action user_delete with "disable" as default

main
Alexander Graf 2 years ago
parent e43f6524ea
commit 30efdf557f
No known key found for this signature in database
GPG Key ID: B8A9DC143E075629

@ -304,6 +304,7 @@ def config_update(verbose=False, delete_objects=False):
if verbose:
print(f'Deleting domain: {domain.name}')
db.session.delete(domain)
db.session.commit()
@ -351,7 +352,7 @@ def config_import(verbose=0, secrets=False, debug=False, quiet=False, color=Fals
raise click.ClickException(msg) from exc
raise
# don't commit when running dry
# do not commit when running dry
if dry_run:
log.changes('Dry run. Not committing changes.')
db.session.rollback()
@ -400,15 +401,29 @@ def config_export(full=False, secrets=False, color=False, dns=False, output=None
finally:
os.umask(old_umask)
@mailu.command()
@click.argument('email')
@click.option('-r', '--really', is_flag=True)
@with_appcontext
def user_delete(email, really=False):
"""disable or delete user"""
if user := models.User.query.get(email):
if really:
db.session.delete(user)
else:
user.enabled = False
db.session.commit()
@mailu.command()
@click.argument('email')
@with_appcontext
def alias_delete(email):
"""delete alias"""
alias = models.Alias.query.get(email)
if alias:
if alias := models.Alias.query.get(email):
db.session.delete(alias)
db.session.commit()
db.session.commit()
@mailu.command()

@ -9,6 +9,7 @@ Managing users and aliases can be done from CLI using commands:
* password
* user
* user-import
* user-delete
* config-update
* config-export
* config-import
@ -62,6 +63,19 @@ primary difference with simple `user` command is that password is being imported
docker-compose run --rm admin flask mailu user-import myuser example.net '$6$51ebe0cb9f1dab48effa2a0ad8660cb489b445936b9ffd812a0b8f46bca66dd549fea530ce' 'SHA512-CRYPT'
user-delete
-----------
Although the action is called "user-delete" the user is only deactivated by default.
This is due to the fact mailu does not remove user-data (emails and webmail contacts) when a user is deleted.
Add the flag `-r` to really delete the user after you have deleted user-data manually.
.. code-block:: bash
docker-compose exec admin flask mailu user-delete foo@example.net
config-update
-------------

Loading…
Cancel
Save