Files
juanjo fbc5f0f6c4
All checks were successful
DEPLOY_MULTI_BRACH/pipeline/head This commit looks good
fix: reemplazar referencias a api_hub_dispatcher por api_config
ROOT_URLCONF, WSGI_APPLICATION, DJANGO_SETTINGS_MODULE apuntaban al
módulo renombrado — causaba ModuleNotFoundError al arrancar en Docker.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-17 01:13:52 +02:00

34 lines
1023 B
Python

from django.contrib.auth import authenticate
from rest_framework.authtoken.models import Token
from rest_framework_simplejwt.tokens import RefreshToken
class Admin:
def get_status_action(self):
# Tu lógica de status que ya tenías
return {"status": "ok", "service": "Admin Infrastructure"}
def obtener_token_action(self, params):
"""
Capa Action: Valida credenciales y genera un par de tokens JWT.
"""
username = params.get('username')
password = params.get('password')
# 1. Autenticación
user = authenticate(username=username, password=password)
if user is not None:
# 2. Generación de JWT (Access & Refresh)
refresh = RefreshToken.for_user(user)
return {
'refresh': str(refresh),
'access': str(refresh.access_token),
'user': user.username,
'status': 'success'
}
return None