Update password in commandline

master
hoellen 5 years ago
parent ba22fb0007
commit 616d40d225

@ -85,6 +85,26 @@ def user(localpart, domain_name, password, hash_scheme=None):
db.session.commit() db.session.commit()
@mailu.command()
@click.argument('localpart')
@click.argument('domain_name')
@click.argument('password')
@click.argument('hash_scheme', required=False)
@flask_cli.with_appcontext
def password(localpart, domain_name, password, hash_scheme=None):
""" Change the password of an user
"""
email = '{0}@{1}'.format(localpart, domain_name)
user = models.User.query.get(email)
if hash_scheme is None:
hash_scheme = app.config['PASSWORD_SCHEME']
if user:
user.set_password(password, hash_scheme=hash_scheme)
else:
print("User " + email + " not found.")
db.session.commit()
@mailu.command() @mailu.command()
@click.argument('domain_name') @click.argument('domain_name')
@click.option('-u', '--max-users') @click.option('-u', '--max-users')

@ -6,6 +6,7 @@ Managing users and aliases can be done from CLI using commands:
* alias * alias
* alias-delete * alias-delete
* domain * domain
* password
* user * user
* user-import * user-import
* user-delete * user-delete
@ -35,6 +36,14 @@ domain
docker-compose exec admin flask mailu domain example.net docker-compose exec admin flask mailu domain example.net
password
--------
.. code-block:: bash
docker-compose exec admin flask mailu password myuser example.net 'password123'
user user
---- ----

@ -0,0 +1 @@
Update user password in commandline
Loading…
Cancel
Save