Añadido soporte para autenticación con Google y mejoras en la gestión de tokens

This commit is contained in:
Mireya Cueto Garrido
2026-04-09 11:39:00 +02:00
parent ffab8ccce6
commit ed44d2f9fd
5 changed files with 116 additions and 5 deletions
+5 -3
View File
@@ -17,7 +17,7 @@ def verify_password(plain_password: str, hashed_password: str) -> bool:
def generate_token() -> str:
return secrets.token_hex(32) # 64 caracteres seguros
return secrets.token_hex(32)
security_scheme = HTTPBearer()
@@ -35,6 +35,8 @@ async def get_current_user(
detail="Token inválido o usuario no autenticado",
)
# devolvemos el documento tal cual (dict)
user["id"] = str(user["_id"])
return user
return user
def create_access_token(data: dict):
return jwt.encode(data, SECRET_KEY, algorithm="HS256")