mirror of
https://github.com/janeczku/calibre-web.git
synced 2024-11-28 08:58:41 +02:00
Moving import LDAP
Correct optional-requirements-ldap.txt spelling
This commit is contained in:
parent
82e4f11334
commit
7ccc40cf5b
@ -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
|
||||
|
||||
|
@ -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")
|
||||
|
Loading…
Reference in New Issue
Block a user