This commit is contained in:
el 2025-06-24 18:17:53 +02:00
commit d7666f7b2c
44 changed files with 2246 additions and 0 deletions

20
backend/crud/user.py Normal file
View file

@ -0,0 +1,20 @@
from sqlalchemy.orm import Session
# Importations ABSOLUES
from models import user as models_user
from schemas import user as schemas_user
from core.hashing import get_password_hash # <-- NOUVEAU
def get_user_by_email(db: Session, email: str):
return db.query(models_user.User).filter(models_user.User.email == email).first()
def create_user(db: Session, user: schemas_user.UserCreate):
hashed_password = get_password_hash(user.password)
db_user = models_user.User(
email=user.email,
hashed_password=hashed_password,
name=user.name
)
db.add(db_user)
db.commit()
db.refresh(db_user)
return db_user