manejo del get

parent 75016f5e
from django.shortcuts import HttpResponseRedirect
#from django.core.urlresolvers import reverse
from django.urls import reverse
class AuthRequiredMiddleware(object):
def __init__(self, get_response):
self.get_response = get_response
def __init__(self, get_response):
self.get_response = get_response
def __call__(self, request):
# Code to be executed for each request before
# the view (and later middleware) are called.
def __call__(self, request):
# Procesar cada solicitud antes de que la vista sea llamada
response = self.get_response(request)
print(request.path_info) # Para depuración
response = self.get_response(request)
print (request.path_info)
print (reverse('login'))
# Excluir ciertas rutas del middleware de autenticación
if "/catalog/streaming/" in request.path_info:
return response
print(request.path_info)
if "/catalog/api/" in request.path_info:
# Permitir todas las rutas de la API (si es necesario)
return response
if "/catalog/streaming/" in request.path_info:
return response
if "/catalog/api/" in request.path_info:
return response
if request.path_info == reverse('ws-news-list2') or request.path_info == reverse('signup') or request.path_info == reverse('status'):
return response
# Excluir específicamente la vista run_update_and_report de la autenticación
if request.path_info == reverse('run_update_and_report'):
return response
if not request.user.is_authenticated and request.path_info != reverse('login'):
return HttpResponseRedirect(reverse('login'))
# Excluir otras vistas como ws-news-list2, signup, etc.
if request.path_info == reverse('ws-news-list2') or request.path_info == reverse('signup') or request.path_info == reverse('status'):
return response
# Code to be executed for each request/response after
# the view is called.
# Redirigir a la página de login si el usuario no está autenticado
if not request.user.is_authenticated and request.path_info != reverse('login'):
return HttpResponseRedirect(reverse('login'))
return response
return response
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment