Merge branch 'master' into master
This commit is contained in:
+13
-11
@@ -1,4 +1,3 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# This file is part of the Calibre-Web (https://github.com/janeczku/calibre-web)
|
||||
@@ -124,12 +123,6 @@ def load_user(user_id):
|
||||
|
||||
@lm.request_loader
|
||||
def load_user_from_request(request):
|
||||
auth_header = request.headers.get("Authorization")
|
||||
if auth_header:
|
||||
user = load_user_from_auth_header(auth_header)
|
||||
if user:
|
||||
return user
|
||||
|
||||
if config.config_allow_reverse_proxy_header_login:
|
||||
rp_header_name = config.config_reverse_proxy_login_header_name
|
||||
if rp_header_name:
|
||||
@@ -139,6 +132,12 @@ def load_user_from_request(request):
|
||||
if user:
|
||||
return user
|
||||
|
||||
auth_header = request.headers.get("Authorization")
|
||||
if auth_header:
|
||||
user = load_user_from_auth_header(auth_header)
|
||||
if user:
|
||||
return user
|
||||
|
||||
return
|
||||
|
||||
|
||||
@@ -150,7 +149,7 @@ def load_user_from_auth_header(header_val):
|
||||
header_val = base64.b64decode(header_val).decode('utf-8')
|
||||
basic_username = header_val.split(':')[0]
|
||||
basic_password = header_val.split(':')[1]
|
||||
except TypeError:
|
||||
except (TypeError, UnicodeDecodeError):
|
||||
pass
|
||||
user = _fetch_user_by_name(basic_username)
|
||||
if user and check_password_hash(str(user.password), basic_password):
|
||||
@@ -172,7 +171,7 @@ def remote_login_required(f):
|
||||
def inner(*args, **kwargs):
|
||||
if config.config_remote_login:
|
||||
return f(*args, **kwargs)
|
||||
if request.is_xhr:
|
||||
if request.headers.get('X-Requested-With') == 'XMLHttpRequest':
|
||||
data = {'status': 'error', 'message': 'Forbidden'}
|
||||
response = make_response(json.dumps(data, ensure_ascii=False))
|
||||
response.headers["Content-Type"] = "application/json; charset=utf-8"
|
||||
@@ -1068,7 +1067,10 @@ def send_to_kindle(book_id, book_format, convert):
|
||||
flash(_(u"There was an error sending this book: %(res)s", res=result), category="error")
|
||||
else:
|
||||
flash(_(u"Please configure your kindle e-mail address first..."), category="error")
|
||||
return redirect(request.environ["HTTP_REFERER"])
|
||||
if "HTTP_REFERER" in request.environ:
|
||||
return redirect(request.environ["HTTP_REFERER"])
|
||||
else:
|
||||
return redirect(url_for('web.index'))
|
||||
|
||||
|
||||
# ################################### Login Logout ##################################################################
|
||||
@@ -1468,7 +1470,7 @@ def show_book(book_id):
|
||||
audioentries.append(media_format.format.lower())
|
||||
|
||||
return render_title_template('detail.html', entry=entries, audioentries=audioentries, cc=cc,
|
||||
is_xhr=request.is_xhr, title=entries.title, books_shelfs=book_in_shelfs,
|
||||
is_xhr=request.headers.get('X-Requested-With')=='XMLHttpRequest', title=entries.title, books_shelfs=book_in_shelfs,
|
||||
have_read=have_read, kindle_list=kindle_list, reader_list=reader_list, page="book")
|
||||
else:
|
||||
log.debug(u"Error opening eBook. File does not exist or file is not accessible:")
|
||||
|
||||
Reference in New Issue
Block a user