|
|
@ -41,7 +41,7 @@ from werkzeug.exceptions import default_exceptions
|
|
|
|
from werkzeug.datastructures import Headers
|
|
|
|
from werkzeug.datastructures import Headers
|
|
|
|
from werkzeug.security import generate_password_hash, check_password_hash
|
|
|
|
from werkzeug.security import generate_password_hash, check_password_hash
|
|
|
|
|
|
|
|
|
|
|
|
from . import constants, logger, isoLanguages, ldap
|
|
|
|
from . import constants, logger, isoLanguages, ldap1
|
|
|
|
from . import global_WorkerThread, searched_ids, lm, babel, db, ub, config, get_locale, app, language_table
|
|
|
|
from . import global_WorkerThread, searched_ids, lm, babel, db, ub, config, get_locale, app, language_table
|
|
|
|
from .gdriveutils import getFileFromEbooksFolder, do_gdrive_download
|
|
|
|
from .gdriveutils import getFileFromEbooksFolder, do_gdrive_download
|
|
|
|
from .helper import common_filters, get_search_results, fill_indexpage, speaking_language, check_valid_domain, \
|
|
|
|
from .helper import common_filters, get_search_results, fill_indexpage, speaking_language, check_valid_domain, \
|
|
|
@ -52,7 +52,7 @@ from .pagination import Pagination
|
|
|
|
from .redirect import redirect_back
|
|
|
|
from .redirect import redirect_back
|
|
|
|
|
|
|
|
|
|
|
|
feature_support = dict()
|
|
|
|
feature_support = dict()
|
|
|
|
feature_support['ldap'] = ldap.ldap_supported()
|
|
|
|
feature_support['ldap'] = ldap1.ldap_supported()
|
|
|
|
|
|
|
|
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
from .oauth_bb import oauth_check, register_user_with_oauth, logout_oauth_user, get_oauth_status
|
|
|
|
from .oauth_bb import oauth_check, register_user_with_oauth, logout_oauth_user, get_oauth_status
|
|
|
@ -1093,17 +1093,17 @@ def login():
|
|
|
|
.first()
|
|
|
|
.first()
|
|
|
|
if config.config_login_type == 1 and user and feature_support['ldap']:
|
|
|
|
if config.config_login_type == 1 and user and feature_support['ldap']:
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
if ldap.ldap.bind_user(form['username'], form['password']) is not None:
|
|
|
|
if ldap1.ldap.bind_user(form['username'], form['password']) is not None:
|
|
|
|
login_user(user, remember=True)
|
|
|
|
login_user(user, remember=True)
|
|
|
|
flash(_(u"you are now logged in as: '%(nickname)s'", nickname=user.nickname),
|
|
|
|
flash(_(u"you are now logged in as: '%(nickname)s'", nickname=user.nickname),
|
|
|
|
category="success")
|
|
|
|
category="success")
|
|
|
|
return redirect_back(url_for("web.index"))
|
|
|
|
return redirect_back(url_for("web.index"))
|
|
|
|
except ldap.ldap.INVALID_CREDENTIALS as e:
|
|
|
|
except ldap1.ldap.INVALID_CREDENTIALS as e:
|
|
|
|
log.error('Login Error: ' + str(e))
|
|
|
|
log.error('Login Error: ' + str(e))
|
|
|
|
ipAdress = request.headers.get('X-Forwarded-For', request.remote_addr)
|
|
|
|
ipAdress = request.headers.get('X-Forwarded-For', request.remote_addr)
|
|
|
|
log.info('LDAP Login failed for user "%s" IP-adress: %s', form['username'], ipAdress)
|
|
|
|
log.info('LDAP Login failed for user "%s" IP-adress: %s', form['username'], ipAdress)
|
|
|
|
flash(_(u"Wrong Username or Password"), category="error")
|
|
|
|
flash(_(u"Wrong Username or Password"), category="error")
|
|
|
|
except ldap.ldap.SERVER_DOWN:
|
|
|
|
except ldap1.ldap.SERVER_DOWN:
|
|
|
|
log.info('LDAP Login failed, LDAP Server down')
|
|
|
|
log.info('LDAP Login failed, LDAP Server down')
|
|
|
|
flash(_(u"Could not login. LDAP server down, please contact your administrator"), category="error")
|
|
|
|
flash(_(u"Could not login. LDAP server down, please contact your administrator"), category="error")
|
|
|
|
'''except LDAPException as exception:
|
|
|
|
'''except LDAPException as exception:
|
|
|
|