ProdLaunch
This commit is contained in:
@@ -47,6 +47,7 @@ limiter = Limiter(key_func=get_remote_address)
|
||||
summary="Login con email e password",
|
||||
description="Autentica l'utente. Se 2FA è attivo, richiede anche il codice TOTP.",
|
||||
)
|
||||
@limiter.limit(settings.rate_limit_auth)
|
||||
async def login(
|
||||
request: Request,
|
||||
body: LoginRequest,
|
||||
@@ -64,6 +65,11 @@ async def login(
|
||||
user_agent=ua,
|
||||
)
|
||||
|
||||
# Commit esplicito prima di restituire la risposta: garantisce che il
|
||||
# RefreshToken sia gia' in DB quando il client chiama /auth/refresh
|
||||
# in sequenza rapida, evitando race condition.
|
||||
await db.commit()
|
||||
|
||||
return TokenResponse(
|
||||
access_token=access_token,
|
||||
refresh_token=refresh_token,
|
||||
@@ -83,6 +89,11 @@ async def refresh_tokens(
|
||||
service = AuthService(db)
|
||||
access_token, refresh_token = await service.refresh_tokens(body.refresh_token)
|
||||
|
||||
# Commit esplicito prima di restituire la risposta: garantisce che la
|
||||
# revoca del vecchio token (rotation) sia persistita in DB prima che
|
||||
# il client possa usare il nuovo token, evitando race condition.
|
||||
await db.commit()
|
||||
|
||||
return TokenResponse(
|
||||
access_token=access_token,
|
||||
refresh_token=refresh_token,
|
||||
|
||||
Reference in New Issue
Block a user