mirror of
https://github.com/janeczku/calibre-web
synced 2024-11-28 20:39:59 +00:00
Clean some comment
This commit is contained in:
parent
91f0908059
commit
2e37c14d94
@ -157,10 +157,8 @@ class UserBase:
|
|||||||
@staticmethod
|
@staticmethod
|
||||||
def try_login(username, password):
|
def try_login(username, password):
|
||||||
conn = get_ldap_connection()
|
conn = get_ldap_connection()
|
||||||
print "bind : {}".format(config.config_ldap_dn)
|
|
||||||
print "replace :{}".format(config.config_ldap_dn.replace("%s", username))
|
|
||||||
conn.simple_bind_s(
|
conn.simple_bind_s(
|
||||||
'uid={},ou=users,dc=yunohost,dc=org'.format(username),
|
config.config_ldap_dn.replace("%s", username),
|
||||||
password
|
password
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -804,7 +802,6 @@ else:
|
|||||||
|
|
||||||
#get LDAP connection
|
#get LDAP connection
|
||||||
def get_ldap_connection():
|
def get_ldap_connection():
|
||||||
print "login to LDAP server ldap://{}".format(config.config_ldap_provider_url)
|
|
||||||
conn = ldap.initialize('ldap://{}'.format(config.config_ldap_provider_url))
|
conn = ldap.initialize('ldap://{}'.format(config.config_ldap_provider_url))
|
||||||
return conn
|
return conn
|
||||||
|
|
||||||
|
@ -2343,8 +2343,9 @@ def login():
|
|||||||
if request.method == "POST":
|
if request.method == "POST":
|
||||||
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 ub.User.try_login(form['username'], form['password']):
|
if config.config_use_ldap and user:
|
||||||
try:
|
try:
|
||||||
|
ub.User.try_login(form['username'], form['password'])
|
||||||
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")
|
||||||
return redirect_back(url_for("index"))
|
return redirect_back(url_for("index"))
|
||||||
@ -3076,7 +3077,7 @@ def configuration_helper(origin):
|
|||||||
|
|
||||||
#LDAP configuratop,
|
#LDAP configuratop,
|
||||||
if "config_use_ldap" in to_save and to_save["config_use_ldap"] == "on":
|
if "config_use_ldap" in to_save and to_save["config_use_ldap"] == "on":
|
||||||
if not "config_ldap_provider_url" in to_save or not "content.config_ldap_dn" in to_save:
|
if not "config_ldap_provider_url" in to_save or not "config_ldap_dn" in to_save:
|
||||||
ub.session.commit()
|
ub.session.commit()
|
||||||
flash(_(u'Please enter a LDAP provider and a DN'), category="error")
|
flash(_(u'Please enter a LDAP provider and a DN'), category="error")
|
||||||
return render_title_template("config_edit.html", content=config, origin=origin,
|
return render_title_template("config_edit.html", content=config, origin=origin,
|
||||||
|
Loading…
Reference in New Issue
Block a user