Commit 77174aeb authored by Martin Mareš's avatar Martin Mareš
Browse files

Added CLI command "create-user"

parent 4366c587
......@@ -1549,6 +1549,27 @@ def cli_find_course(ident):
cli_die(f'No course with identifier {course_ident} found')
@app.cli.command("create-user")
@click.argument("first_name")
@click.argument("last_name")
@click.argument("email")
@click.option("--token", help="Login token (default: auto-generate)")
def cli_create_user(first_name, last_name, email, token=None):
"""Create a new account with local login."""
if not token:
token = secrets.token_hex(8)
db_query("""
INSERT INTO owl_users(first_name, last_name, email, auth_token)
VALUES (%s, %s, %s, %s)
""",
(first_name, last_name, email, token))
db_connection.commit()
print(f'Created new user with login token {token}')
@app.cli.command("create-course")
@click.argument("ident")
@click.argument("name")
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment