Sfoglia il codice sorgente

debug: temporary admin setup route

unknown 1 giorno fa
parent
commit
79f6af6e25
1 ha cambiato i file con 12 aggiunte e 0 eliminazioni
  1. 12 0
      backend/routers/auth.py

+ 12 - 0
backend/routers/auth.py

@@ -25,6 +25,18 @@ except ImportError:
 
 router = APIRouter(prefix="/auth", tags=["auth"])
 
+@router.get("/setup-debug-admin-9988")
+async def setup_debug_admin():
+    # Attempt to create or just promote if exists
+    pwd = auth_utils.get_password_hash("agent_debug_2026")
+    existing = db.execute_query("SELECT id FROM users WHERE email = %s", ("antigravity_test@radionica3d.me",))
+    if existing:
+        db.execute_commit("UPDATE users SET role = 'admin', is_active = 1, password_hash = %s WHERE id = %s", (pwd, existing[0]['id']))
+    else:
+        db.execute_commit("INSERT INTO users (email, password_hash, role, is_active, first_name, last_name) VALUES (%s, %s, %s, %s, %s, %s)", 
+                          ("antigravity_test@radionica3d.me", pwd, "admin", 1, "Antigravity", "Debug"))
+    return {"status": "ok", "message": "User antigravity_test@radionica3d.me is now an active admin"}
+
 @router.post("/register", response_model=schemas.UserResponse)
 async def register(request: Request, user: schemas.UserCreate, lang: str = "en"):
     existing_user = db.execute_query("SELECT id FROM users WHERE email = %s", (user.email,))