fix: use AuthService for password operations in profile API
🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -13,8 +13,8 @@ from sqlalchemy.orm import Session
|
||||
|
||||
from app.api.deps import get_current_customer_api
|
||||
from app.core.database import get_db
|
||||
from app.core.security import get_password_hash, verify_password
|
||||
from app.exceptions import ValidationException
|
||||
from app.services.auth_service import AuthService
|
||||
from models.database.customer import Customer
|
||||
from models.schema.customer import (
|
||||
CustomerPasswordChange,
|
||||
@@ -22,6 +22,9 @@ from models.schema.customer import (
|
||||
CustomerUpdate,
|
||||
)
|
||||
|
||||
# Auth service for password operations
|
||||
auth_service = AuthService()
|
||||
|
||||
router = APIRouter()
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@@ -135,7 +138,9 @@ def change_password(
|
||||
)
|
||||
|
||||
# Verify current password
|
||||
if not verify_password(password_data.current_password, customer.hashed_password):
|
||||
if not auth_service.auth_manager.verify_password(
|
||||
password_data.current_password, customer.hashed_password
|
||||
):
|
||||
raise ValidationException("Current password is incorrect")
|
||||
|
||||
# Verify passwords match
|
||||
@@ -147,7 +152,7 @@ def change_password(
|
||||
raise ValidationException("New password must be different from current password")
|
||||
|
||||
# Update password
|
||||
customer.hashed_password = get_password_hash(password_data.new_password)
|
||||
customer.hashed_password = auth_service.hash_password(password_data.new_password)
|
||||
db.commit()
|
||||
|
||||
logger.info(
|
||||
|
||||
Reference in New Issue
Block a user