JSON WEBTOKENS!!
This commit is contained in:
@@ -10,6 +10,7 @@ class UserModel(Base):
|
||||
nombre = Column(String(100), nullable=False, index=True)
|
||||
apellido = Column(String(100), nullable=False, index=True)
|
||||
email = Column(String(255), unique=True, nullable=False, index=True)
|
||||
contraseña_hash = Column(String(255), nullable=False, default="$2b$12$R9h7cIPz0gi.URNNX3kh2OPST9/PgBkqquzi.Ee3GzxQ2n8/N7kDi") # Hash de "passwd123"
|
||||
fecha_nacimiento = Column(DateTime, nullable=False)
|
||||
fecha_creacion = Column(DateTime, default=datetime.utcnow, nullable=False)
|
||||
calificacion = Column(Float, default=50.0, nullable=False) # 0-100
|
||||
|
||||
@@ -20,6 +20,7 @@ class UserRepositorySQL(UserRepository):
|
||||
nombre=user.nombre,
|
||||
apellido=user.apellido,
|
||||
email=user.email,
|
||||
contraseña_hash=user.contraseña_hash,
|
||||
fecha_nacimiento=user.fecha_nacimiento,
|
||||
fecha_creacion=user.fecha_creacion,
|
||||
calificacion=user.calificacion,
|
||||
@@ -59,6 +60,15 @@ class UserRepositorySQL(UserRepository):
|
||||
logger.error(f"Error al buscar usuario por email {email}: {e}", exc_info=True)
|
||||
raise
|
||||
|
||||
def find_by_email_with_password(self, email: str) -> Optional[UserModel]:
|
||||
"""Obtiene un usuario por email incluyendo el hash de contraseña (para autenticación)"""
|
||||
try:
|
||||
db_user = self.db.query(UserModel).filter(UserModel.email == email).first()
|
||||
return db_user
|
||||
except Exception as e:
|
||||
logger.error(f"Error al buscar usuario por email {email}: {e}", exc_info=True)
|
||||
raise
|
||||
|
||||
def find_all(self) -> List[User]:
|
||||
"""Obtiene todos los usuarios"""
|
||||
try:
|
||||
|
||||
@@ -28,6 +28,7 @@ class UserMessage:
|
||||
nombre: Optional[str] = None
|
||||
apellido: Optional[str] = None
|
||||
email: Optional[str] = None
|
||||
contraseña_hash: Optional[str] = None
|
||||
fecha_nacimiento: Optional[str] = None # ISO format datetime string
|
||||
fecha_creacion: Optional[str] = None # ISO format datetime string
|
||||
calificacion: Optional[float] = None
|
||||
|
||||
Reference in New Issue
Block a user