Renombrar actions.py a acciones.py en backend_admin y promociones
All checks were successful
DEPLOY_MULTI_BRACH/pipeline/head This commit looks good
DEPLOY_MULTI_BRACH/pipeline/pr-dev This commit looks good

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
juanjo
2026-04-16 15:42:21 +02:00
parent 84baf8fbda
commit 27ccce862d
4 changed files with 2 additions and 2 deletions

View File

@@ -0,0 +1,34 @@
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