1
0
mirror of https://github.com/janeczku/calibre-web synced 2024-12-25 01:20:32 +00:00

Moving import LDAP

Correct optional-requirements-ldap.txt spelling
This commit is contained in:
Krakinou 2019-01-13 11:02:03 +01:00
parent 82e4f11334
commit 7ccc40cf5b
3 changed files with 3 additions and 2 deletions

View File

@ -14,7 +14,6 @@ import json
import datetime
from binascii import hexlify
import cli
import ldap
engine = create_engine('sqlite:///{0}'.format(cli.settingspath), echo=False)
Base = declarative_base()
@ -802,6 +801,7 @@ else:
#get LDAP connection
def get_ldap_connection():
import ldap
conn = ldap.initialize('ldap://{}'.format(config.config_ldap_provider_url))
return conn

View File

@ -57,7 +57,6 @@ from redirect import redirect_back
import time
import server
from reverseproxy import ReverseProxied
import ldap
try:
from googleapiclient.errors import HttpError
@ -2344,6 +2343,7 @@ def login():
form = request.form.to_dict()
user = ub.session.query(ub.User).filter(func.lower(ub.User.nickname) == form['username'].strip().lower()).first()
if config.config_use_ldap and user:
import ldap
try:
ub.User.try_login(form['username'], form['password'])
login_user(user, remember=True)
@ -2352,6 +2352,7 @@ def login():
except ldap.INVALID_CREDENTIALS:
ipAdress = request.headers.get('X-Forwarded-For', request.remote_addr)
app.logger.info('LDAP Login failed for user "' + form['username'] + '" IP-adress: ' + ipAdress)
flash(_(u"Wrong Username or Password"), category="error")
elif user and check_password_hash(user.password, form['password']) and user.nickname is not "Guest" and not user.is_authenticated:
login_user(user, remember=True)
flash(_(u"you are now logged in as: '%(nickname)s'", nickname=user.nickname), category="success")