diff options
| author | raven <citrons@mondecitronne.com> | 2026-11-02 01:08:05 -0600 |
|---|---|---|
| committer | raven <citrons@mondecitronne.com> | 2026-11-02 01:09:49 -0600 |
| commit | 32f37da6c6c33957a73a98695268ff581041e604 (patch) | |
| tree | 60279303f35d74a4a69f6fcf945a65a496b97419 | |
| parent | 2a6c11a2ef112f590267af88c384b3ab91b02b33 (diff) | |
create_admin command for easy testing
| -rw-r--r-- | apioforum/db.py | 12 |
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) |
