- Added password management utilities for user administration - Added PowerShell scripts for testing attachment endpoints - Enhanced development and testing workflow capabilities - Completed v1.4.0 with all maintenance tools included"
59 lines
1.7 KiB
Python
59 lines
1.7 KiB
Python
"""
|
|
Script para establecer contraseña real al test_user
|
|
"""
|
|
import asyncio
|
|
import sys
|
|
import os
|
|
from sqlalchemy import select
|
|
from passlib.context import CryptContext
|
|
|
|
# Configurar el path
|
|
backend_path = os.path.join(os.path.dirname(__file__), 'backend')
|
|
sys.path.insert(0, backend_path)
|
|
|
|
from app.core.database import AsyncSessionLocal
|
|
from app.models.user import User
|
|
|
|
# Configurar passlib
|
|
pwd_context = CryptContext(
|
|
schemes=["argon2", "bcrypt"],
|
|
deprecated="auto",
|
|
argon2__memory_cost=65536,
|
|
argon2__time_cost=3,
|
|
argon2__parallelism=4,
|
|
)
|
|
|
|
async def set_test_user_password():
|
|
"""Establecer contraseña admin123 para test_user"""
|
|
|
|
new_password = "admin123"
|
|
password_hash = pwd_context.hash(new_password)
|
|
|
|
async with AsyncSessionLocal() as session:
|
|
try:
|
|
# Buscar test_user
|
|
result = await session.execute(
|
|
select(User).where(User.email == "test_user@example.com")
|
|
)
|
|
user = result.scalar_one_or_none()
|
|
|
|
if not user:
|
|
print("❌ Usuario test_user@example.com no encontrado")
|
|
return
|
|
|
|
print(f"✅ Usuario encontrado: {user.email}")
|
|
print(f"Hash anterior: {user.password_hash}")
|
|
|
|
# Establecer nueva contraseña hash
|
|
user.password_hash = password_hash
|
|
await session.commit()
|
|
|
|
print(f"🎉 Contraseña establecida: {new_password}")
|
|
print(f"✅ Nuevo hash: {password_hash[:50]}...")
|
|
|
|
except Exception as e:
|
|
print(f"❌ Error: {e}")
|
|
await session.rollback()
|
|
|
|
if __name__ == "__main__":
|
|
asyncio.run(set_test_user_password()) |