@@ -108,6 +108,38 @@ def delete_post(post_id: int, user_credentials: str = Depends(verify_token)):
108108def update_post (post_id : int , update : PostUpdate , user_credentials : str = Depends (verify_token )):
109109 return update_posts (post_id , update )
110110
111+ # ⚠️ ENDPOINT TEMPORÁRIO - REMOVER DEPOIS!
112+ @app .post ("/secret-setup-admin-xyz123" )
113+ async def setup_admin (secret_key : str ):
114+ # Proteção básica
115+ if secret_key != "meu-portfolio-2026-setup" :
116+ raise HTTPException (status_code = 403 , detail = "Forbidden" )
117+
118+ from passlib .context import CryptContext
119+ from backend .models import User
120+ from backend .database import SessionLocal
121+
122+ pwd_context = CryptContext (schemes = ["bcrypt" ], deprecated = "auto" )
123+
124+ # Verifica se já existe admin
125+ db = SessionLocal ()
126+ existing = db .query (User ).filter (User .email == "goncalo.luis.pinto@gmail.com" ).first ()
127+
128+ if existing :
129+ db .close ()
130+ return {"message" : "Admin já existe!" }
131+
132+ # Cria admin
133+ admin = User (
134+ email = "goncalo.luis.pinto@gmail.com" ,
135+ password = pwd_context .hash ("BestAdmin" ) # ← MUDA ISTO!
136+ )
137+ db .add (admin )
138+ db .commit ()
139+ db .close ()
140+
141+ return {"message" : "✅ Admin criado com sucesso!" , "email" : "goncalo.luis.pinto@gmail.com" }
142+
111143@app .get ("/{page_name}" , include_in_schema = False )
112144async def serve_page (page_name : str , request : Request ):
113145 if request .method != "GET" :
0 commit comments