mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-04-11 10:00:48 -05:00
Fix pep8 style
This commit is contained in:
parent
060d3011f7
commit
a698c69b4d
@ -2,6 +2,7 @@ from django.contrib.auth.mixins import AccessMixin
|
|||||||
from django.contrib.auth import authenticate, login
|
from django.contrib.auth import authenticate, login
|
||||||
import base64
|
import base64
|
||||||
|
|
||||||
|
|
||||||
class Renderable(object):
|
class Renderable(object):
|
||||||
"""
|
"""
|
||||||
A handy mixin to make it easier/cleaner to print output based on a
|
A handy mixin to make it easier/cleaner to print output based on a
|
||||||
@ -12,12 +13,13 @@ class Renderable(object):
|
|||||||
if self.verbosity >= verbosity:
|
if self.verbosity >= verbosity:
|
||||||
print(text)
|
print(text)
|
||||||
|
|
||||||
|
|
||||||
class SessionOrBasicAuthMixin(AccessMixin):
|
class SessionOrBasicAuthMixin(AccessMixin):
|
||||||
"""
|
"""
|
||||||
Session or Basic Authentication mixin for Django.
|
Session or Basic Authentication mixin for Django.
|
||||||
It determines if the requester is already logged in or if they have provided
|
It determines if the requester is already logged in or if they have
|
||||||
proper http-authorization and returning the view if all goes well, otherwise
|
provided proper http-authorization and returning the view if all goes
|
||||||
responding with a 401.
|
well, otherwise responding with a 401.
|
||||||
|
|
||||||
Base for mixin found here: https://djangosnippets.org/snippets/3073/
|
Base for mixin found here: https://djangosnippets.org/snippets/3073/
|
||||||
"""
|
"""
|
||||||
@ -38,13 +40,16 @@ class SessionOrBasicAuthMixin(AccessMixin):
|
|||||||
if len(auth) == 2:
|
if len(auth) == 2:
|
||||||
# NOTE: Support for only basic authentication
|
# NOTE: Support for only basic authentication
|
||||||
if auth[0].lower() == "basic":
|
if auth[0].lower() == "basic":
|
||||||
uname, passwd = base64.b64decode(auth[1]).decode('utf-8').split(':')
|
authString = base64.b64decode(auth[1]).decode('utf-8')
|
||||||
|
uname, passwd = authString.split(':')
|
||||||
user = authenticate(username=uname, password=passwd)
|
user = authenticate(username=uname, password=passwd)
|
||||||
if user is not None:
|
if user is not None:
|
||||||
if user.is_active:
|
if user.is_active:
|
||||||
login(request, user)
|
login(request, user)
|
||||||
request.user = user
|
request.user = user
|
||||||
return super(SessionOrBasicAuthMixin, self).dispatch(
|
return super(
|
||||||
|
SessionOrBasicAuthMixin, self
|
||||||
|
).dispatch(
|
||||||
request, *args, **kwargs
|
request, *args, **kwargs
|
||||||
)
|
)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user