fix: disable public signup and restore local login flow
This commit is contained in:
19
app/cli.py
19
app/cli.py
@@ -3,7 +3,7 @@ from __future__ import annotations
|
||||
import click
|
||||
|
||||
from .extensions import db
|
||||
from .models import BadgeDefinition
|
||||
from .models import BadgeDefinition, User
|
||||
from .services.monthly import archive_months_missing_up_to_previous
|
||||
from .services.notifications import send_due_notifications, send_monthly_winner_notifications
|
||||
|
||||
@@ -54,6 +54,22 @@ def register_cli(app) -> None:
|
||||
seed_badges()
|
||||
click.echo("Datenbank und Standard-Badges sind bereit.")
|
||||
|
||||
@app.cli.command("create-user")
|
||||
@click.option("--name", prompt=True, help="Anzeigename")
|
||||
@click.option("--email", prompt=True, help="E-Mail")
|
||||
@click.option("--password", prompt=True, hide_input=True, confirmation_prompt=True, help="Passwort")
|
||||
def create_user_command(name: str, email: str, password: str):
|
||||
existing = User.query.filter_by(email=email.lower().strip()).first()
|
||||
if existing:
|
||||
click.echo("Es existiert bereits ein Nutzer mit dieser E-Mail.")
|
||||
raise SystemExit(1)
|
||||
|
||||
user = User(name=name.strip(), email=email.lower().strip())
|
||||
user.set_password(password)
|
||||
db.session.add(user)
|
||||
db.session.commit()
|
||||
click.echo(f"Nutzer {user.email} wurde angelegt.")
|
||||
|
||||
@app.cli.command("archive-months")
|
||||
def archive_months_command():
|
||||
archive_months_missing_up_to_previous()
|
||||
@@ -68,4 +84,3 @@ def register_cli(app) -> None:
|
||||
def notify_monthly_winner_command():
|
||||
result = send_monthly_winner_notifications()
|
||||
click.echo(f"Winner-Push: sent={result.sent} skipped={result.skipped} failed={result.failed}")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user