2025-07-26 20:04:24 +02:00
|
|
|
# services/auth/app/api/auth.py - Fixed Login Method
|
2025-07-17 13:09:24 +02:00
|
|
|
"""
|
2025-07-26 20:04:24 +02:00
|
|
|
Authentication API endpoints - FIXED VERSION
|
2025-07-17 13:09:24 +02:00
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
from fastapi import APIRouter, Depends, HTTPException, status, Request
|
2025-07-20 08:33:23 +02:00
|
|
|
from fastapi.security import HTTPBearer, HTTPAuthorizationCredentials
|
2025-07-17 13:09:24 +02:00
|
|
|
from sqlalchemy.ext.asyncio import AsyncSession
|
2025-07-18 14:41:39 +02:00
|
|
|
import structlog
|
2025-07-17 13:09:24 +02:00
|
|
|
|
|
|
|
|
from app.core.database import get_db
|
2025-07-20 08:33:23 +02:00
|
|
|
from app.core.security import SecurityManager
|
2025-07-26 20:04:24 +02:00
|
|
|
from app.services.auth_service import AuthService
|
|
|
|
|
from app.schemas.auth import PasswordReset, UserRegistration, UserLogin, TokenResponse, RefreshTokenRequest, PasswordChange
|
2025-07-20 08:33:23 +02:00
|
|
|
from shared.monitoring.decorators import track_execution_time
|
2025-07-26 20:04:24 +02:00
|
|
|
from shared.monitoring.metrics import get_metrics_collector
|
2025-07-17 13:09:24 +02:00
|
|
|
|
2025-07-18 14:41:39 +02:00
|
|
|
logger = structlog.get_logger()
|
2025-07-17 13:09:24 +02:00
|
|
|
|
2025-07-26 20:04:24 +02:00
|
|
|
router = APIRouter()
|
|
|
|
|
security = HTTPBearer()
|
2025-07-20 08:33:23 +02:00
|
|
|
|
2025-07-26 22:03:55 +02:00
|
|
|
@router.post("/register", response_model=TokenResponse)
|
|
|
|
|
@track_execution_time("registration_duration_seconds", "auth-service")
|
|
|
|
|
async def register(
|
|
|
|
|
user_data: UserRegistration,
|
2025-07-18 12:34:28 +02:00
|
|
|
request: Request,
|
2025-07-17 13:09:24 +02:00
|
|
|
db: AsyncSession = Depends(get_db)
|
|
|
|
|
):
|
2025-07-26 22:03:55 +02:00
|
|
|
"""Register new user with enhanced debugging"""
|
2025-07-18 12:34:28 +02:00
|
|
|
metrics = get_metrics_collector(request)
|
|
|
|
|
|
2025-07-26 22:03:55 +02:00
|
|
|
# ✅ DEBUG: Log incoming registration data (without password)
|
|
|
|
|
logger.info(f"Registration attempt for email: {user_data.email}")
|
|
|
|
|
logger.debug(f"Registration data - email: {user_data.email}, full_name: {user_data.full_name}")
|
|
|
|
|
|
2025-07-17 13:09:24 +02:00
|
|
|
try:
|
2025-07-26 22:03:55 +02:00
|
|
|
# ✅ DEBUG: Validate input data
|
|
|
|
|
if not user_data.email or not user_data.email.strip():
|
2025-07-20 08:33:23 +02:00
|
|
|
raise HTTPException(
|
2025-07-26 22:03:55 +02:00
|
|
|
status_code=status.HTTP_400_BAD_REQUEST,
|
|
|
|
|
detail="Email is required"
|
2025-07-20 08:33:23 +02:00
|
|
|
)
|
|
|
|
|
|
2025-07-26 22:03:55 +02:00
|
|
|
if not user_data.password or len(user_data.password) < 8:
|
|
|
|
|
raise HTTPException(
|
|
|
|
|
status_code=status.HTTP_400_BAD_REQUEST,
|
|
|
|
|
detail="Password must be at least 8 characters long"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
if not user_data.full_name or not user_data.full_name.strip():
|
|
|
|
|
raise HTTPException(
|
|
|
|
|
status_code=status.HTTP_400_BAD_REQUEST,
|
|
|
|
|
detail="Full name is required"
|
|
|
|
|
)
|
2025-07-18 12:34:28 +02:00
|
|
|
|
2025-07-26 22:03:55 +02:00
|
|
|
logger.debug(f"Input validation passed for {user_data.email}")
|
2025-07-18 12:34:28 +02:00
|
|
|
|
2025-07-26 22:03:55 +02:00
|
|
|
# ✅ DEBUG: Call auth service with enhanced error tracking
|
|
|
|
|
result = await AuthService.register_user_with_tokens(
|
|
|
|
|
email=user_data.email.strip().lower(), # Normalize email
|
|
|
|
|
password=user_data.password,
|
|
|
|
|
full_name=user_data.full_name.strip(),
|
|
|
|
|
db=db
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
logger.info(f"Registration successful for {user_data.email}")
|
|
|
|
|
|
|
|
|
|
# Record successful registration
|
2025-07-26 20:04:24 +02:00
|
|
|
if metrics:
|
2025-07-26 22:03:55 +02:00
|
|
|
metrics.increment_counter("registration_total", labels={"status": "success"})
|
2025-07-20 08:33:23 +02:00
|
|
|
|
2025-07-26 22:03:55 +02:00
|
|
|
# ✅ DEBUG: Validate response before returning
|
|
|
|
|
if not result.get("access_token"):
|
|
|
|
|
logger.error(f"Registration succeeded but no access_token in result for {user_data.email}")
|
|
|
|
|
raise HTTPException(
|
|
|
|
|
status_code=status.HTTP_500_INTERNAL_SERVER_ERROR,
|
|
|
|
|
detail="Registration completed but token generation failed"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
logger.debug(f"Returning token response for {user_data.email}")
|
2025-07-22 13:46:05 +02:00
|
|
|
return TokenResponse(**result)
|
2025-07-18 12:34:28 +02:00
|
|
|
|
|
|
|
|
except HTTPException as e:
|
2025-07-26 22:03:55 +02:00
|
|
|
# Record failed registration with specific error
|
2025-07-18 12:34:28 +02:00
|
|
|
if metrics:
|
2025-07-26 22:03:55 +02:00
|
|
|
error_type = "validation_error" if e.status_code == 400 else "conflict" if e.status_code == 409 else "failed"
|
|
|
|
|
metrics.increment_counter("registration_total", labels={"status": error_type})
|
2025-07-26 20:04:24 +02:00
|
|
|
|
2025-07-26 22:03:55 +02:00
|
|
|
logger.warning(f"Registration failed for {user_data.email}: {e.detail}")
|
2025-07-17 13:09:24 +02:00
|
|
|
raise
|
2025-07-26 20:04:24 +02:00
|
|
|
|
2025-07-17 13:09:24 +02:00
|
|
|
except Exception as e:
|
2025-07-26 22:03:55 +02:00
|
|
|
# Record registration system error
|
2025-07-18 12:34:28 +02:00
|
|
|
if metrics:
|
2025-07-26 22:03:55 +02:00
|
|
|
metrics.increment_counter("registration_total", labels={"status": "error"})
|
|
|
|
|
|
|
|
|
|
logger.error(f"Registration system error for {user_data.email}: {str(e)}", exc_info=True)
|
|
|
|
|
|
|
|
|
|
# ✅ DEBUG: Provide more specific error information in development
|
|
|
|
|
error_detail = f"Registration failed: {str(e)}" if logger.level == "DEBUG" else "Registration failed"
|
2025-07-26 20:04:24 +02:00
|
|
|
|
2025-07-17 13:09:24 +02:00
|
|
|
raise HTTPException(
|
|
|
|
|
status_code=status.HTTP_500_INTERNAL_SERVER_ERROR,
|
2025-07-26 22:03:55 +02:00
|
|
|
detail=error_detail
|
2025-07-17 13:09:24 +02:00
|
|
|
)
|
|
|
|
|
|
2025-07-26 22:03:55 +02:00
|
|
|
@router.post("/login", response_model=TokenResponse)
|
|
|
|
|
@track_execution_time("login_duration_seconds", "auth-service")
|
|
|
|
|
async def login(
|
|
|
|
|
login_data: UserLogin,
|
2025-07-17 13:09:24 +02:00
|
|
|
request: Request,
|
|
|
|
|
db: AsyncSession = Depends(get_db)
|
|
|
|
|
):
|
2025-07-26 22:03:55 +02:00
|
|
|
"""Login user with enhanced debugging"""
|
2025-07-18 12:34:28 +02:00
|
|
|
metrics = get_metrics_collector(request)
|
|
|
|
|
|
2025-07-26 22:03:55 +02:00
|
|
|
logger.info(f"Login attempt for email: {login_data.email}")
|
|
|
|
|
|
2025-07-17 13:09:24 +02:00
|
|
|
try:
|
2025-07-26 22:03:55 +02:00
|
|
|
# ✅ DEBUG: Validate login data
|
|
|
|
|
if not login_data.email or not login_data.email.strip():
|
|
|
|
|
raise HTTPException(
|
|
|
|
|
status_code=status.HTTP_400_BAD_REQUEST,
|
|
|
|
|
detail="Email is required"
|
|
|
|
|
)
|
2025-07-18 12:34:28 +02:00
|
|
|
|
2025-07-26 22:03:55 +02:00
|
|
|
if not login_data.password:
|
|
|
|
|
raise HTTPException(
|
|
|
|
|
status_code=status.HTTP_400_BAD_REQUEST,
|
|
|
|
|
detail="Password is required"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
# Attempt login through AuthService
|
|
|
|
|
result = await AuthService.login(
|
|
|
|
|
email=login_data.email.strip().lower(), # Normalize email
|
|
|
|
|
password=login_data.password,
|
|
|
|
|
db=db
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
# Record successful login
|
2025-07-18 12:34:28 +02:00
|
|
|
if metrics:
|
2025-07-26 22:03:55 +02:00
|
|
|
metrics.increment_counter("login_success_total")
|
2025-07-18 12:34:28 +02:00
|
|
|
|
2025-07-26 22:03:55 +02:00
|
|
|
logger.info(f"Login successful for {login_data.email}")
|
2025-07-20 08:33:23 +02:00
|
|
|
return TokenResponse(**result)
|
2025-07-18 12:34:28 +02:00
|
|
|
|
2025-07-17 21:25:27 +02:00
|
|
|
except HTTPException as e:
|
2025-07-26 22:03:55 +02:00
|
|
|
# Record failed login with specific reason
|
2025-07-18 12:34:28 +02:00
|
|
|
if metrics:
|
2025-07-26 22:03:55 +02:00
|
|
|
reason = "validation_error" if e.status_code == 400 else "auth_failed"
|
|
|
|
|
metrics.increment_counter("login_failure_total", labels={"reason": reason})
|
|
|
|
|
|
|
|
|
|
logger.warning(f"Login failed for {login_data.email}: {e.detail}")
|
2025-07-17 13:09:24 +02:00
|
|
|
raise
|
2025-07-26 22:03:55 +02:00
|
|
|
|
2025-07-17 13:09:24 +02:00
|
|
|
except Exception as e:
|
2025-07-26 22:03:55 +02:00
|
|
|
# Record login system error
|
2025-07-18 12:34:28 +02:00
|
|
|
if metrics:
|
2025-07-26 22:03:55 +02:00
|
|
|
metrics.increment_counter("login_failure_total", labels={"reason": "error"})
|
|
|
|
|
|
|
|
|
|
logger.error(f"Login system error for {login_data.email}: {str(e)}", exc_info=True)
|
2025-07-17 13:09:24 +02:00
|
|
|
raise HTTPException(
|
|
|
|
|
status_code=status.HTTP_500_INTERNAL_SERVER_ERROR,
|
2025-07-26 22:03:55 +02:00
|
|
|
detail="Login failed"
|
2025-07-17 13:09:24 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
@router.post("/refresh", response_model=TokenResponse)
|
2025-07-18 12:34:28 +02:00
|
|
|
@track_execution_time("token_refresh_duration_seconds", "auth-service")
|
2025-07-17 13:09:24 +02:00
|
|
|
async def refresh_token(
|
|
|
|
|
refresh_data: RefreshTokenRequest,
|
2025-07-18 12:34:28 +02:00
|
|
|
request: Request,
|
2025-07-17 13:09:24 +02:00
|
|
|
db: AsyncSession = Depends(get_db)
|
|
|
|
|
):
|
|
|
|
|
"""Refresh access token"""
|
2025-07-18 12:34:28 +02:00
|
|
|
metrics = get_metrics_collector(request)
|
|
|
|
|
|
2025-07-17 13:09:24 +02:00
|
|
|
try:
|
2025-07-20 08:33:23 +02:00
|
|
|
result = await AuthService.refresh_access_token(refresh_data.refresh_token, db)
|
2025-07-18 12:34:28 +02:00
|
|
|
|
|
|
|
|
# Record successful refresh
|
|
|
|
|
if metrics:
|
2025-07-20 08:33:23 +02:00
|
|
|
metrics.increment_counter("token_refresh_success_total")
|
2025-07-18 12:34:28 +02:00
|
|
|
|
2025-07-20 08:33:23 +02:00
|
|
|
return TokenResponse(**result)
|
2025-07-18 12:34:28 +02:00
|
|
|
|
|
|
|
|
except HTTPException as e:
|
|
|
|
|
if metrics:
|
2025-07-20 08:33:23 +02:00
|
|
|
metrics.increment_counter("token_refresh_failure_total")
|
|
|
|
|
logger.warning(f"Token refresh failed: {e.detail}")
|
2025-07-17 13:09:24 +02:00
|
|
|
raise
|
|
|
|
|
except Exception as e:
|
2025-07-18 12:34:28 +02:00
|
|
|
if metrics:
|
2025-07-20 08:33:23 +02:00
|
|
|
metrics.increment_counter("token_refresh_failure_total")
|
2025-07-17 13:09:24 +02:00
|
|
|
logger.error(f"Token refresh error: {e}")
|
|
|
|
|
raise HTTPException(
|
|
|
|
|
status_code=status.HTTP_500_INTERNAL_SERVER_ERROR,
|
|
|
|
|
detail="Token refresh failed"
|
|
|
|
|
)
|
|
|
|
|
|
2025-07-26 20:04:24 +02:00
|
|
|
@router.post("/verify")
|
|
|
|
|
@track_execution_time("token_verify_duration_seconds", "auth-service")
|
2025-07-17 13:09:24 +02:00
|
|
|
async def verify_token(
|
2025-07-20 08:33:23 +02:00
|
|
|
credentials: HTTPAuthorizationCredentials = Depends(security),
|
|
|
|
|
request: Request = None
|
2025-07-17 13:09:24 +02:00
|
|
|
):
|
2025-07-26 20:04:24 +02:00
|
|
|
"""Verify access token and return user info"""
|
2025-07-20 08:33:23 +02:00
|
|
|
metrics = get_metrics_collector(request) if request else None
|
2025-07-18 12:34:28 +02:00
|
|
|
|
2025-07-17 13:09:24 +02:00
|
|
|
try:
|
2025-07-26 20:04:24 +02:00
|
|
|
if not credentials:
|
|
|
|
|
raise HTTPException(
|
|
|
|
|
status_code=status.HTTP_401_UNAUTHORIZED,
|
|
|
|
|
detail="Authentication required"
|
|
|
|
|
)
|
|
|
|
|
|
2025-07-22 13:46:05 +02:00
|
|
|
result = await AuthService.verify_user_token(credentials.credentials)
|
2025-07-17 13:09:24 +02:00
|
|
|
|
2025-07-26 20:04:24 +02:00
|
|
|
# Record successful verification
|
2025-07-18 12:34:28 +02:00
|
|
|
if metrics:
|
2025-07-22 13:46:05 +02:00
|
|
|
metrics.increment_counter("token_verify_success_total")
|
2025-07-18 12:34:28 +02:00
|
|
|
|
2025-07-26 20:04:24 +02:00
|
|
|
return {
|
|
|
|
|
"valid": True,
|
|
|
|
|
"user_id": result.get("user_id"),
|
|
|
|
|
"email": result.get("email"),
|
|
|
|
|
"exp": result.get("exp"),
|
|
|
|
|
"message": None
|
|
|
|
|
}
|
2025-07-18 12:34:28 +02:00
|
|
|
|
|
|
|
|
except HTTPException as e:
|
|
|
|
|
if metrics:
|
2025-07-22 13:46:05 +02:00
|
|
|
metrics.increment_counter("token_verify_failure_total")
|
2025-07-26 20:04:24 +02:00
|
|
|
logger.warning(f"Token verification failed: {e.detail}")
|
2025-07-17 13:09:24 +02:00
|
|
|
raise
|
|
|
|
|
except Exception as e:
|
2025-07-18 12:34:28 +02:00
|
|
|
if metrics:
|
2025-07-22 13:46:05 +02:00
|
|
|
metrics.increment_counter("token_verify_failure_total")
|
2025-07-17 13:09:24 +02:00
|
|
|
logger.error(f"Token verification error: {e}")
|
|
|
|
|
raise HTTPException(
|
2025-07-20 08:33:23 +02:00
|
|
|
status_code=status.HTTP_401_UNAUTHORIZED,
|
|
|
|
|
detail="Invalid token"
|
2025-07-17 13:09:24 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
@router.post("/logout")
|
2025-07-22 13:46:05 +02:00
|
|
|
@track_execution_time("logout_duration_seconds", "auth-service")
|
2025-07-17 13:09:24 +02:00
|
|
|
async def logout(
|
2025-07-20 08:33:23 +02:00
|
|
|
refresh_data: RefreshTokenRequest,
|
2025-07-17 13:09:24 +02:00
|
|
|
request: Request,
|
|
|
|
|
db: AsyncSession = Depends(get_db)
|
|
|
|
|
):
|
2025-07-22 13:46:05 +02:00
|
|
|
"""Logout user by revoking refresh token"""
|
2025-07-18 12:34:28 +02:00
|
|
|
metrics = get_metrics_collector(request)
|
|
|
|
|
|
2025-07-17 13:09:24 +02:00
|
|
|
try:
|
2025-07-20 08:33:23 +02:00
|
|
|
success = await AuthService.logout(refresh_data.refresh_token, db)
|
|
|
|
|
|
|
|
|
|
if metrics:
|
2025-07-22 13:46:05 +02:00
|
|
|
status_label = "success" if success else "failed"
|
|
|
|
|
metrics.increment_counter("logout_total", labels={"status": status_label})
|
2025-07-20 08:33:23 +02:00
|
|
|
|
2025-07-22 13:46:05 +02:00
|
|
|
return {"message": "Logout successful" if success else "Logout failed"}
|
2025-07-20 08:33:23 +02:00
|
|
|
|
|
|
|
|
except Exception as e:
|
|
|
|
|
if metrics:
|
|
|
|
|
metrics.increment_counter("logout_total", labels={"status": "error"})
|
|
|
|
|
logger.error(f"Logout error: {e}")
|
|
|
|
|
raise HTTPException(
|
|
|
|
|
status_code=status.HTTP_500_INTERNAL_SERVER_ERROR,
|
|
|
|
|
detail="Logout failed"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
# ================================================================
|
|
|
|
|
# PASSWORD MANAGEMENT ENDPOINTS
|
|
|
|
|
# ================================================================
|
|
|
|
|
|
|
|
|
|
@router.post("/change-password")
|
|
|
|
|
async def change_password(
|
|
|
|
|
password_data: PasswordChange,
|
|
|
|
|
credentials: HTTPAuthorizationCredentials = Depends(security),
|
|
|
|
|
request: Request = None,
|
|
|
|
|
db: AsyncSession = Depends(get_db)
|
|
|
|
|
):
|
|
|
|
|
"""Change user password"""
|
|
|
|
|
metrics = get_metrics_collector(request) if request else None
|
|
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
if not credentials:
|
2025-07-18 12:34:28 +02:00
|
|
|
raise HTTPException(
|
|
|
|
|
status_code=status.HTTP_401_UNAUTHORIZED,
|
2025-07-20 08:33:23 +02:00
|
|
|
detail="Authentication required"
|
2025-07-18 12:34:28 +02:00
|
|
|
)
|
|
|
|
|
|
2025-07-20 08:33:23 +02:00
|
|
|
# Verify current token
|
|
|
|
|
payload = await AuthService.verify_user_token(credentials.credentials)
|
|
|
|
|
user_id = payload.get("user_id")
|
2025-07-18 12:34:28 +02:00
|
|
|
|
2025-07-20 08:33:23 +02:00
|
|
|
if not user_id:
|
|
|
|
|
raise HTTPException(
|
|
|
|
|
status_code=status.HTTP_401_UNAUTHORIZED,
|
|
|
|
|
detail="Invalid token"
|
|
|
|
|
)
|
2025-07-18 12:34:28 +02:00
|
|
|
|
2025-07-20 08:33:23 +02:00
|
|
|
# Validate new password
|
|
|
|
|
if not SecurityManager.validate_password(password_data.new_password):
|
|
|
|
|
raise HTTPException(
|
|
|
|
|
status_code=status.HTTP_400_BAD_REQUEST,
|
|
|
|
|
detail="New password does not meet security requirements"
|
|
|
|
|
)
|
2025-07-18 12:34:28 +02:00
|
|
|
|
2025-07-20 08:33:23 +02:00
|
|
|
# Change password logic would go here
|
|
|
|
|
# This is a simplified version - you'd need to implement the actual password change in AuthService
|
|
|
|
|
|
|
|
|
|
# Record password change
|
2025-07-18 12:34:28 +02:00
|
|
|
if metrics:
|
2025-07-20 08:33:23 +02:00
|
|
|
metrics.increment_counter("password_change_total", labels={"status": "success"})
|
|
|
|
|
|
|
|
|
|
logger.info(f"Password changed for user: {user_id}")
|
|
|
|
|
return {"message": "Password changed successfully"}
|
|
|
|
|
|
|
|
|
|
except HTTPException:
|
2025-07-18 12:34:28 +02:00
|
|
|
raise
|
2025-07-20 08:33:23 +02:00
|
|
|
except Exception as e:
|
|
|
|
|
# Record password change error
|
|
|
|
|
if metrics:
|
|
|
|
|
metrics.increment_counter("password_change_total", labels={"status": "error"})
|
|
|
|
|
logger.error(f"Password change error: {e}")
|
|
|
|
|
raise HTTPException(
|
|
|
|
|
status_code=status.HTTP_500_INTERNAL_SERVER_ERROR,
|
|
|
|
|
detail="Password change failed"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
@router.post("/reset-password")
|
|
|
|
|
async def reset_password(
|
|
|
|
|
reset_data: PasswordReset,
|
|
|
|
|
request: Request,
|
|
|
|
|
db: AsyncSession = Depends(get_db)
|
|
|
|
|
):
|
|
|
|
|
"""Request password reset"""
|
|
|
|
|
metrics = get_metrics_collector(request)
|
|
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
# Password reset logic would go here
|
|
|
|
|
# This is a simplified version - you'd need to implement email sending, etc.
|
|
|
|
|
|
|
|
|
|
# Record password reset request
|
|
|
|
|
if metrics:
|
|
|
|
|
metrics.increment_counter("password_reset_total", labels={"status": "requested"})
|
|
|
|
|
|
|
|
|
|
logger.info(f"Password reset requested for: {reset_data.email}")
|
|
|
|
|
return {"message": "Password reset email sent if account exists"}
|
2025-07-18 12:34:28 +02:00
|
|
|
|
2025-07-17 13:09:24 +02:00
|
|
|
except Exception as e:
|
2025-07-20 08:33:23 +02:00
|
|
|
# Record password reset error
|
2025-07-18 12:34:28 +02:00
|
|
|
if metrics:
|
2025-07-20 08:33:23 +02:00
|
|
|
metrics.increment_counter("password_reset_total", labels={"status": "error"})
|
|
|
|
|
logger.error(f"Password reset error: {e}")
|
2025-07-17 13:09:24 +02:00
|
|
|
raise HTTPException(
|
|
|
|
|
status_code=status.HTTP_500_INTERNAL_SERVER_ERROR,
|
2025-07-20 08:33:23 +02:00
|
|
|
detail="Password reset failed"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
# ================================================================
|
|
|
|
|
# HEALTH AND STATUS ENDPOINTS
|
|
|
|
|
# ================================================================
|
|
|
|
|
|
|
|
|
|
@router.get("/health")
|
|
|
|
|
async def health_check():
|
|
|
|
|
"""Health check endpoint"""
|
|
|
|
|
return {
|
|
|
|
|
"status": "healthy",
|
|
|
|
|
"service": "auth-service",
|
|
|
|
|
"version": "1.0.0"
|
|
|
|
|
}
|