Skip to content

Instantly share code, notes, and snippets.

@Allwin12
Created October 22, 2020 13:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Allwin12/10c838fdfa3c88f44ecd0940e0127566 to your computer and use it in GitHub Desktop.
Save Allwin12/10c838fdfa3c88f44ecd0940e0127566 to your computer and use it in GitHub Desktop.
from django.http import HttpResponse
from django.utils.deprecation import MiddlewareMixin
class ProcessRequestMiddleware(MiddlewareMixin):
def process_view(self, request, view_func, *view_args, **view_kwargs):
user = request.user
if user.is_authenticated:
return HttpResponse(status=200)
else:
return HttpResponse('Unauthorised', status=401)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment