Ultimo Commit antes del apagon (Respaldo)
This commit is contained in:
@@ -17,12 +17,12 @@ from .views import (
|
||||
CheckVersionView,
|
||||
UploadZipVersionView,
|
||||
Sistema_CreateView,
|
||||
Custom_Login,
|
||||
|
||||
|
||||
#function
|
||||
download_version_FromServer,
|
||||
uploadZipViewHTML,
|
||||
|
||||
)
|
||||
urlpatterns = [
|
||||
path('',SistemasXCliente_ListView.as_view(),name='lista_sistmas'),
|
||||
@@ -39,4 +39,5 @@ urlpatterns = [
|
||||
path('download_version_FromServer/',download_version_FromServer, name='downloadVersionFromServer'),
|
||||
path('uploadZip/', UploadZipVersionView.as_view(), name='uploadZip'),
|
||||
path('uploadZip2/', uploadZipViewHTML, name="uploadZipViewHTML"),
|
||||
path('login/', Custom_Login.as_view(), name="Customlogin"),
|
||||
]
|
||||
@@ -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})
|
||||
Reference in New Issue
Block a user