Ultimo Commit antes del apagon (Respaldo)

This commit is contained in:
fjrodriguez
2023-05-03 11:06:27 -06:00
parent 3b70ad09ca
commit 8b9b17a79d
21 changed files with 515 additions and 17 deletions

View File

@@ -15,6 +15,8 @@ from rest_framework.response import Response
from rest_framework.permissions import IsAuthenticated
from rest_framework import status, permissions
from django.contrib.auth.models import User
from django.contrib.auth import authenticate, login
from django.contrib import messages
from django.contrib.auth.mixins import LoginRequiredMixin, UserPassesTestMixin
@@ -221,6 +223,7 @@ class Sistema_CreateView(CreateView):
========================= API Views
'''
class GetDeviceToken(APIView):
"""Recobra el Token DRF del Device"""
authentication_classes= [TokenAuthentication]
@@ -344,3 +347,23 @@ class CheckVersionView(APIView):
except Exception as ex:
BitacoraErrores.objects.create(level=2, message=str(ex), traceback=traceback.format_exc(), view='Sistemas.CheckVersionView')
return Response({'Error':f'{ex}','isError':True})
class Custom_Login(APIView):
"""Autentica al device"""
authentication_classes= [TokenAuthentication]
permissions_classes=[IsAuthenticated, HasAuthorizationHeader]
def post(self, request):
username = request.data.get('username')
password = request.data.get('password')
try:
user = authenticate(request, username=username,password=password)
if user is not None:
login(request,user)
return Response({'access':True})
else:
return Response({'access':False})
except Exception as ex:
BitacoraErrores.objects.create(level=2, message=str(ex), traceback=traceback.format_exc(), view='Sistemas.Custom_Login')
return Response({'access':False})