prod: UI Optimisée mise en production
- Documentation archivée et réorganisée - Backend: Ajout tests, migrations, library service, rate limiting - Frontend: Suppression Flutter, focus sur interface web HTML/JS - Tailwind CSS ajouté pour le style - Améliorations UX et corrections bugs Generated with [Claude Code](https://claude.com/claude-code) via [Happy](https://happy.engineering) Co-Authored-By: Claude <noreply@anthropic.com> Co-Authored-By: Happy <yesreply@happy.engineering>
This commit is contained in:
@@ -3,6 +3,7 @@ from fastapi import APIRouter, HTTPException, status
|
||||
|
||||
from app.api.dependencies import AuthServiceDep, CurrentUser, DBSession
|
||||
from app.schemas.auth import (
|
||||
ChangePasswordRequest,
|
||||
LoginRequest,
|
||||
RefreshTokenRequest,
|
||||
Token,
|
||||
@@ -176,3 +177,50 @@ async def logout(
|
||||
# - Log the logout event
|
||||
|
||||
return None
|
||||
|
||||
|
||||
@router.post("/change-password")
|
||||
async def change_password(
|
||||
password_data: ChangePasswordRequest,
|
||||
current_user: CurrentUser,
|
||||
auth_service: AuthServiceDep,
|
||||
db: DBSession,
|
||||
):
|
||||
"""
|
||||
Change user password.
|
||||
|
||||
Requires authentication and current password verification.
|
||||
|
||||
- **password_data**: Object containing old_password and new_password
|
||||
"""
|
||||
from app.core.security import verify_password, hash_password
|
||||
|
||||
# Verify old password
|
||||
if not verify_password(password_data.old_password, current_user.password_hash):
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_401_UNAUTHORIZED,
|
||||
detail="Current password is incorrect"
|
||||
)
|
||||
|
||||
# Validate new password
|
||||
if len(password_data.new_password) < 8:
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_400_BAD_REQUEST,
|
||||
detail="New password must be at least 8 characters"
|
||||
)
|
||||
|
||||
if password_data.old_password == password_data.new_password:
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_400_BAD_REQUEST,
|
||||
detail="New password must be different from current password"
|
||||
)
|
||||
|
||||
# Hash new password
|
||||
new_password_hash = hash_password(password_data.new_password)
|
||||
|
||||
# Update password
|
||||
current_user.password_hash = new_password_hash
|
||||
await db.commit()
|
||||
await db.refresh(current_user)
|
||||
|
||||
return {"message": "Password changed successfully"}
|
||||
|
||||
Reference in New Issue
Block a user