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