From 2e37c14d94e254c03f9733676cd144ce33c8af96 Mon Sep 17 00:00:00 2001 From: Krakinou Date: Sat, 12 Jan 2019 18:40:32 +0100 Subject: [PATCH] Clean some comment --- cps/ub.py | 5 +---- cps/web.py | 5 +++-- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/cps/ub.py b/cps/ub.py index 6de9059c..e541763e 100644 --- a/cps/ub.py +++ b/cps/ub.py @@ -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 diff --git a/cps/web.py b/cps/web.py index aaf3e02b..e7c687fd 100644 --- a/cps/web.py +++ b/cps/web.py @@ -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,