aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--apioforum/db.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/apioforum/db.py b/apioforum/db.py
index 9dcf1ee..024aae9 100644
--- a/apioforum/db.py
+++ b/apioforum/db.py
@@ -305,7 +305,19 @@ def migrate_command():
init_db()
click.echo("ok")
+@click.command("create_admin")
+@click.argument("username")
+@with_appcontext
+def create_admin_command(username):
+ db = get_db()
+ from werkzeug.security import generate_password_hash
+ db.execute(
+ "INSERT INTO users (username, password, admin) VALUES (?,?,1);",
+ (username, generate_password_hash("changeme")))
+ db.commit()
+
def init_app(app):
app.teardown_appcontext(close_db)
app.cli.add_command(migrate_command)
+ app.cli.add_command(create_admin_command)