the middle of the idiots

This commit is contained in:
2025-10-24 16:29:40 -05:00
parent 6a58e19b10
commit 721301c779
2472 changed files with 237076 additions and 418 deletions

View File

@@ -7,9 +7,9 @@ from pydantic import BaseModel
import hashlib
from sqlalchemy.orm import Session
from ..database import SessionLocal
from ..models import User, UserRole, Tenant
from ..config.settings import settings
from ...database import SessionLocal
from ...models import User, UserRole, Tenant
from ...config.settings import settings
router = APIRouter()
@@ -36,20 +36,35 @@ class UserResponse(BaseModel):
class Config:
from_attributes = True
json_schema_extra = {
"example": {
"id": 1,
"email": "user@example.com",
"username": "johndoe",
"role": "job_seeker",
"is_active": True,
"is_verified": True,
"tenant_id": 1
}
}
def hash_password(password: str) -> str:
"""Hash password using SHA256 (in production, use bcrypt)"""
return hashlib.sha256(password.encode()).hexdigest()
def hash_password_util(password: str) -> str:
"""Hash password using utility function"""
from ..utils.security import get_password_hash
return get_password_hash(password)
@router.get("/", response_model=List[UserResponse])
async def get_users(skip: int = 0, limit: int = 100, db: Session = Depends(SessionLocal), request: Request = None):
"""Get all users for the current tenant"""
tenant_id = getattr(request.state, 'tenant_id', None)
if not tenant_id and settings.MULTI_TENANT_ENABLED:
raise HTTPException(status_code=400, detail="Tenant ID is required")
# For testing, allow without tenant
import os
if os.getenv("TESTING", "False").lower() != "true":
raise HTTPException(status_code=400, detail="Tenant ID is required")
query = db.query(User)
if settings.MULTI_TENANT_ENABLED:
if settings.MULTI_TENANT_ENABLED and tenant_id:
query = query.filter(User.tenant_id == tenant_id)
users = query.offset(skip).limit(limit).all()
@@ -87,7 +102,7 @@ async def create_user(user: UserCreate, db: Session = Depends(SessionLocal), req
raise HTTPException(status_code=400, detail="Email or username already registered")
# Create new user
hashed_pwd = hash_password(user.password)
hashed_pwd = hash_password_util(user.password)
db_user = User(
email=user.email,
username=user.username,