added setting PAPERLESS_AUTO_LOGIN_USERNAME

This commit is contained in:
Jonas Winkler
2020-11-23 22:50:02 +01:00
parent 6ab1d01252
commit b275297a05
5 changed files with 92 additions and 52 deletions

View File

@@ -1,8 +1,18 @@
from django.conf import settings
from django.contrib.auth.models import User
from django.utils.deprecation import MiddlewareMixin
from rest_framework import authentication
class AutoLoginMiddleware(MiddlewareMixin):
def process_request(self, request):
try:
request.user = User.objects.get(username=settings.AUTO_LOGIN_USERNAME)
except User.DoesNotExist:
pass
class AngularApiAuthenticationOverride(authentication.BaseAuthentication):
""" This class is here to provide authentication to the angular dev server
during development. This is disabled in production.