Clean some comment
This commit is contained in:
parent
91f0908059
commit
2e37c14d94
|
@ -157,10 +157,8 @@ class UserBase:
|
|||
@staticmethod
|
||||
def try_login(username, password):
|
||||
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(
|
||||
'uid={},ou=users,dc=yunohost,dc=org'.format(username),
|
||||
config.config_ldap_dn.replace("%s", username),
|
||||
password
|
||||
)
|
||||
|
||||
|
@ -804,7 +802,6 @@ else:
|
|||
|
||||
#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))
|
||||
return conn
|
||||
|
||||
|
|
|
@ -2343,8 +2343,9 @@ def login():
|
|||
if request.method == "POST":
|
||||
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 ub.User.try_login(form['username'], form['password']):
|
||||
if config.config_use_ldap and user:
|
||||
try:
|
||||
ub.User.try_login(form['username'], form['password'])
|
||||
login_user(user, remember=True)
|
||||
flash(_(u"you are now logged in as: '%(nickname)s'", nickname=user.nickname), category="success")
|
||||
return redirect_back(url_for("index"))
|
||||
|
@ -3076,7 +3077,7 @@ def configuration_helper(origin):
|
|||
|
||||
#LDAP configuratop,
|
||||
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()
|
||||
flash(_(u'Please enter a LDAP provider and a DN'), category="error")
|
||||
return render_title_template("config_edit.html", content=config, origin=origin,
|
||||
|
|
Loading…
Reference in New Issue
Block a user