fix: Windows path handling, light theme default, file viewer in editor, first-user admin logic
Config: - Fixed SQLite path parsing on Windows (handle drive letters without prepending /) - Changed default theme from dark to light - Updated OAuth test credentials (gitea_oauth_client_id/secret) Auth: - First real user (excluding default admin with no password) becomes admin - Changed user count query to exclude users without password_hash File viewer: - Removed separate _render_file_viewer() —
This commit is contained in:
+5
-3
@@ -153,9 +153,11 @@ async def register(request: Request):
|
||||
if existing:
|
||||
from fastapi.responses import JSONResponse
|
||||
return JSONResponse({"error": "Account already exists"}, status_code=409)
|
||||
# First user is admin
|
||||
user_count = conn.execute("SELECT COUNT(*) FROM users").fetchone()[0]
|
||||
is_admin = 1 if user_count == 0 else 0
|
||||
# First real user (excluding default admin with no password) is admin
|
||||
real_user_count = conn.execute(
|
||||
"SELECT COUNT(*) FROM users WHERE password_hash IS NOT NULL AND password_hash != ''"
|
||||
).fetchone()[0]
|
||||
is_admin = 1 if real_user_count == 0 else 0
|
||||
conn.execute(
|
||||
"INSERT INTO users (login, full_name, email, password_hash, is_admin) VALUES (?, ?, ?, ?, ?)",
|
||||
(email, name, email, hash_password(password), is_admin),
|
||||
|
||||
Reference in New Issue
Block a user