1
0
mirror of https://github.com/janeczku/calibre-web synced 2024-11-24 18:47:23 +00:00

Fix #1838 (Log message on failed OPDS login)

This commit is contained in:
Ozzie Isaacs 2021-01-28 20:05:58 +01:00
parent e6799e7a04
commit 34a474101f
2 changed files with 8 additions and 2 deletions

View File

@ -32,7 +32,7 @@ from tempfile import gettempdir
import requests import requests
from babel.dates import format_datetime from babel.dates import format_datetime
from babel.units import format_unit from babel.units import format_unit
from flask import send_from_directory, make_response, redirect, abort, url_for from flask import send_from_directory, make_response, redirect, abort, url_for, request
from flask_babel import gettext as _ from flask_babel import gettext as _
from flask_login import current_user from flask_login import current_user
from sqlalchemy.sql.expression import true, false, and_, text from sqlalchemy.sql.expression import true, false, and_, text
@ -68,6 +68,7 @@ try:
except (ImportError, RuntimeError) as e: except (ImportError, RuntimeError) as e:
log.debug('Cannot import Image, generating covers from non jpg files will not work: %s', e) log.debug('Cannot import Image, generating covers from non jpg files will not work: %s', e)
use_IM = False use_IM = False
MissingDelegateError = BaseException
# Convert existing book entry to new format # Convert existing book entry to new format

View File

@ -430,7 +430,12 @@ def check_auth(username, password):
username = username.encode('utf-8') username = username.encode('utf-8')
user = ub.session.query(ub.User).filter(func.lower(ub.User.nickname) == user = ub.session.query(ub.User).filter(func.lower(ub.User.nickname) ==
username.decode('utf-8').lower()).first() username.decode('utf-8').lower()).first()
return bool(user and check_password_hash(str(user.password), password)) if bool(user and check_password_hash(str(user.password), password)):
return True
else:
ipAdress = request.headers.get('X-Forwarded-For', request.remote_addr)
log.warning('OPDS Login failed for user "%s" IP-address: %s', username.decode('utf-8'), ipAdress)
return False
def authenticate(): def authenticate():