Set password properly when using the CLI, fixes, #136

master
Pierre Jaury 8 years ago
parent 453fa1cb3f
commit 182e844ae6

@ -1,6 +1,5 @@
from mailu import manager, db from mailu import manager, db
from mailu.admin import models from mailu.admin import models
from passlib import hash
@manager.command @manager.command
@ -28,12 +27,13 @@ def admin(localpart, domain_name, password):
user = models.User( user = models.User(
localpart=localpart, localpart=localpart,
domain=domain, domain=domain,
global_admin=True, global_admin=True
password=hash.sha512_crypt.encrypt(password)
) )
user.set_password(password)
db.session.add(user) db.session.add(user)
db.session.commit() db.session.commit()
@manager.command @manager.command
def user(localpart, domain_name, password): def user(localpart, domain_name, password):
""" Create an user """ Create an user
@ -45,12 +45,13 @@ def user(localpart, domain_name, password):
user = models.User( user = models.User(
localpart=localpart, localpart=localpart,
domain=domain, domain=domain,
global_admin=False, global_admin=False
password=hash.sha512_crypt.encrypt(password)
) )
user.set_password(password)
db.session.add(user) db.session.add(user)
db.session.commit() db.session.commit()
@manager.command @manager.command
def alias(localpart, domain_name, destination): def alias(localpart, domain_name, destination):
""" Create an alias """ Create an alias
@ -59,7 +60,7 @@ def alias(localpart, domain_name, destination):
if not domain: if not domain:
domain = models.Domain(name=domain_name) domain = models.Domain(name=domain_name)
db.session.add(domain) db.session.add(domain)
alias = models.Alias( alias = models.Alias(
localpart=localpart, localpart=localpart,
domain=domain, domain=domain,
destination=destination.split(','), destination=destination.split(','),
@ -68,5 +69,6 @@ def alias(localpart, domain_name, destination):
db.session.add(alias) db.session.add(alias)
db.session.commit() db.session.commit()
if __name__ == "__main__": if __name__ == "__main__":
manager.run() manager.run()

Loading…
Cancel
Save