from fastapi import Depends, HTTPException, Security from fastapi.security import HTTPBearer, HTTPAuthorizationCredentials from psycopg import AsyncConnection from mm_api.db import get_conn import mm_api.services.auth as auth_svc bearer = HTTPBearer(auto_error=False) async def current_user( credentials: HTTPAuthorizationCredentials = Security(bearer), conn: AsyncConnection = Depends(get_conn), ) -> dict: if not credentials: raise HTTPException(401, "Kimlik doğrulama gerekli") user = await auth_svc.get_current_user(conn, credentials.credentials) if not user: raise HTTPException(401, "Geçersiz veya süresi dolmuş token") return user async def verified_user(user: dict = Depends(current_user)) -> dict: if user["kyc_status"] != "verified": raise HTTPException(403, "Kimlik doğrulaması gerekli") return user