feat(fase0): fix title, add change-password endpoint
- index.html: title → "Leopost — Studio Editoriale AI" - auth router: add POST /api/auth/change-password (local accounts only) validates current password, enforces min 8 chars, bcrypt update Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -43,6 +43,11 @@ class RedeemCodeRequest(BaseModel):
|
|||||||
code: str
|
code: str
|
||||||
|
|
||||||
|
|
||||||
|
class ChangePasswordRequest(BaseModel):
|
||||||
|
current_password: str
|
||||||
|
new_password: str
|
||||||
|
|
||||||
|
|
||||||
def _user_response(user: User) -> dict:
|
def _user_response(user: User) -> dict:
|
||||||
return {
|
return {
|
||||||
"id": user.id,
|
"id": user.id,
|
||||||
@@ -231,6 +236,26 @@ async def oauth_google_callback(code: str, state: Optional[str] = None, db: Sess
|
|||||||
return RedirectResponse(url=redirect_url)
|
return RedirectResponse(url=redirect_url)
|
||||||
|
|
||||||
|
|
||||||
|
# === Change password ===
|
||||||
|
|
||||||
|
@router.post("/change-password")
|
||||||
|
def change_password(
|
||||||
|
request: ChangePasswordRequest,
|
||||||
|
db: Session = Depends(get_db),
|
||||||
|
current_user: User = Depends(get_current_user),
|
||||||
|
):
|
||||||
|
"""Change password for the current user (local accounts only)."""
|
||||||
|
if current_user.auth_provider != "local":
|
||||||
|
raise HTTPException(status_code=400, detail="Usa il provider di accesso originale per cambiare la password.")
|
||||||
|
if not verify_password(request.current_password, current_user.hashed_password):
|
||||||
|
raise HTTPException(status_code=400, detail="Password attuale non corretta.")
|
||||||
|
if len(request.new_password) < 8:
|
||||||
|
raise HTTPException(status_code=400, detail="La nuova password deve essere di almeno 8 caratteri.")
|
||||||
|
current_user.hashed_password = hash_password(request.new_password)
|
||||||
|
db.commit()
|
||||||
|
return {"message": "Password aggiornata con successo."}
|
||||||
|
|
||||||
|
|
||||||
# === Subscription code redemption ===
|
# === Subscription code redemption ===
|
||||||
|
|
||||||
@router.post("/redeem")
|
@router.post("/redeem")
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8" />
|
<meta charset="UTF-8" />
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
<title>Leopost Full</title>
|
<title>Leopost — Studio Editoriale AI</title>
|
||||||
<link rel="preconnect" href="https://fonts.googleapis.com" />
|
<link rel="preconnect" href="https://fonts.googleapis.com" />
|
||||||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
|
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
|
||||||
<link href="https://fonts.googleapis.com/css2?family=Fraunces:ital,wght@0,400;0,600;0,700;1,400&family=DM+Sans:wght@400;500;600&display=swap" rel="stylesheet" />
|
<link href="https://fonts.googleapis.com/css2?family=Fraunces:ital,wght@0,400;0,600;0,700;1,400&family=DM+Sans:wght@400;500;600&display=swap" rel="stylesheet" />
|
||||||
|
|||||||
Reference in New Issue
Block a user