Add a global admin account when initializing the database
parent
c52cf53310
commit
54fb9cf60a
@ -1,6 +1,18 @@
|
|||||||
from freeposte import db
|
from freeposte import db, models
|
||||||
|
from passlib import hash
|
||||||
|
|
||||||
|
|
||||||
# Initialize the database
|
# Initialize the database
|
||||||
db.create_all()
|
db.create_all()
|
||||||
|
|
||||||
|
domain = models.Domain(name="example.com")
|
||||||
|
user = models.User(
|
||||||
|
localpart="admin",
|
||||||
|
domain=domain,
|
||||||
|
global_admin=True,
|
||||||
|
password=hash.sha512_crypt.encrypt("admin").
|
||||||
|
)
|
||||||
|
|
||||||
|
db.session.add(domain)
|
||||||
|
db.session.add(user)
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
|
Loading…
Reference in New Issue