X-Git-Url: https://git.mdrn.pl/wolnelektury.git/blobdiff_plain/ae60b2a3949e96357477cc04f90fd0873cee8a92..f5129e7c47fa5fcf0a20f04249b90afcbc54cb9c:/src/basicauth.py?ds=sidebyside diff --git a/src/basicauth.py b/src/basicauth.py index 3635727c4..1275390ed 100644 --- a/src/basicauth.py +++ b/src/basicauth.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- ############################################################################# # from http://djangosnippets.org/snippets/243/ @@ -29,7 +28,7 @@ def view_or_basicauth(view, request, test_func, realm="", *args, **kwargs): # NOTE: We are only support basic authentication for now. # if auth[0].lower() == "basic": - uname, passwd = base64.b64decode(auth[1]).split(':') + uname, passwd = base64.b64decode(auth[1].encode('utf-8')).decode('utf-8').split(':') user = authenticate(username=uname, password=passwd) if user is not None: if user.is_active: @@ -80,7 +79,7 @@ def logged_in_or_basicauth(realm=""): def view_decorator(func): def wrapper(request, *args, **kwargs): return view_or_basicauth(func, request, - lambda u: u.is_authenticated(), + lambda u: u.is_authenticated, realm, *args, **kwargs) return wrapper return view_decorator