refactor: reorganizar estructura del proyecto al estándar app/api_config
All checks were successful
DEPLOY_MULTI_BRACH/pipeline/head This commit looks good
All checks were successful
DEPLOY_MULTI_BRACH/pipeline/head This commit looks good
- core/ → app/api_config/ - apps/backend_admin/ → app/backend_admin/ - apps/common/ → app/common/ - apps/promociones/ → app/promociones/ - manage.py → app/manage.py - Añadir app/requirements.txt - Actualizar todos los imports y referencias (DJANGO_SETTINGS_MODULE, ROOT_URLCONF, WSGI_APPLICATION, INSTALLED_APPS) - Actualizar Dockerfile con nuevo WORKDIR Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
34
app/backend_admin/acciones.py
Normal file
34
app/backend_admin/acciones.py
Normal 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
|
||||
|
||||
Reference in New Issue
Block a user