Subir todos los cambios recientes a la rama principal

This commit is contained in:
arielit3
2026-01-16 13:39:55 -07:00
parent de5b6feef4
commit 99427cd48c
38 changed files with 15383 additions and 66 deletions

View File

@@ -1,41 +1,40 @@
import asyncio
import sys
import os
import json
# Add parent directory to path so we can import 'app'
# Asegurar que el directorio raíz esté en PYTHONPATH
sys.path.append(os.path.dirname(os.path.abspath(__file__)))
from sqlalchemy import select
from app.core.database import AsyncSessionLocal
from app.models.tenant import Tenant # Import Tenant to register it
from app.models.ticket import Ticket # Import Ticket to register it
from app.models.user import User
from app.core.security import SecurityUtils
from app.core.config import settings
from app.models.user import User
from app.models.tenant import Tenant
from app.core.database import AsyncSessionLocal
from sqlalchemy.future import select
import asyncio
async def fix_password():
async with AsyncSessionLocal() as session:
# Find the admin user
email = "admin@aduanasoft.com"
result = await session.execute(select(User).where(User.email == email))
user = result.scalar_one_or_none()
if user:
print(f"User {email} found.")
# Reset password to 'admin123'
new_password = "admin123"
hashed = SecurityUtils.hash_password(new_password)
user.password_hash = hashed
try:
await session.commit()
print(f"Password for {email} updated successfully!")
print(f"New password is: {new_password}")
except Exception as e:
await session.rollback()
print(f"Error updating password: {e}")
else:
print(f"User {email} not found!")
# Generar un token predeterminado para el usuario admin
def generate_default_token():
async def async_task():
async with AsyncSessionLocal() as db:
result = await db.execute(select(User).filter(User.email == "admin@aduanasoft.com"))
user = result.scalar_one_or_none()
if user:
print(f"User found: {user.email}")
token = SecurityUtils.create_access_token({"sub": str(user.id), "email": user.email})
print(f"Generated token: {token}")
if __name__ == "__main__":
asyncio.run(fix_password())
# Validate the token
payload = SecurityUtils.verify_token(token)
if payload:
print("Token is valid. Payload:")
print(json.dumps(payload, indent=4))
else:
print("Token validation failed.")
else:
print("User not found. Token not generated.")
asyncio.run(async_task())
generate_default_token()
print("Token generation process completed.")