Default per-user main.py; invite-only by default

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-05-10 01:45:20 +12:00
parent 6fc651ad72
commit 687a8347f8
7 changed files with 97 additions and 14 deletions

View File

@@ -12,6 +12,7 @@ from sqlalchemy import func, select
from sqlalchemy.orm import Session
from editor_app.db.models import AuthSession, InviteToken, User
from editor_app.services import user_workspace
if TYPE_CHECKING:
pass
@@ -67,6 +68,10 @@ def create_user(db: Session, username: str, password: str, *, is_superuser: bool
db.add(user)
db.commit()
db.refresh(user)
if auth_enabled():
user_workspace.ensure_default_code_main(
user_workspace.user_workspace_root(user.id, user.username)
)
return user
@@ -145,7 +150,7 @@ def delete_user(db: Session, user_id: int) -> bool:
def invite_required() -> bool:
return os.environ.get("AUTH_INVITE_ONLY", "false").strip().lower() in ("1", "true", "yes", "on")
return os.environ.get("AUTH_INVITE_ONLY", "true").strip().lower() in ("1", "true", "yes", "on")
def create_invite(db: Session, email: str, invited_by_user_id: int | None = None, expires_days: int = 7) -> InviteToken: