From 7ccc40cf5b2260b4fe282dab92b6119eda7a22d9 Mon Sep 17 00:00:00 2001 From: Krakinou Date: Sun, 13 Jan 2019 11:02:03 +0100 Subject: [PATCH] Moving import LDAP Correct optional-requirements-ldap.txt spelling --- cps/ub.py | 2 +- cps/web.py | 3 ++- ...nal-requirements-ldap.txt => optional-requirements-ldap.txt | 0 3 files changed, 3 insertions(+), 2 deletions(-) rename optionnal-requirements-ldap.txt => optional-requirements-ldap.txt (100%) diff --git a/cps/ub.py b/cps/ub.py index e541763e..605c8ba0 100644 --- a/cps/ub.py +++ b/cps/ub.py @@ -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 diff --git a/cps/web.py b/cps/web.py index e7c687fd..fca0e16f 100644 --- a/cps/web.py +++ b/cps/web.py @@ -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") diff --git a/optionnal-requirements-ldap.txt b/optional-requirements-ldap.txt similarity index 100% rename from optionnal-requirements-ldap.txt rename to optional-requirements-ldap.txt