Skip to content
Snippets Groups Projects
Commit ae9eecff authored by Alexandre Ferland's avatar Alexandre Ferland
Browse files

return strings instead of bytes for py3

parent 63b0bab9
No related branches found
No related tags found
No related merge requests found
......@@ -64,9 +64,9 @@ copyright = u'2017, Alexandre Ferland'
# built documents.
#
# The short X.Y version.
version = '1.1.2'
version = '1.2.0'
# The full version, including alpha/beta/rc tags.
release = '1.1.2'
release = '1.2.0'
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
......
......@@ -116,6 +116,9 @@ History
Changes:
- 1.2.0 September 26, 2017
- Changed get_group_members() and get_user_groups() returning strings instead of bytes in PY3.
- 1.1.2 July 17, 2017
- Merge GitHub PR `#30 <https://github.com/admiralobvious/flask-simpleldap/pull/30>`_,
Fix for python3
......
......@@ -150,9 +150,6 @@ class LDAP(object):
return
try:
conn = self.initialize
if sys.version_info[0] > 2:
conn.simple_bind_s(user_dn, password)
else:
conn.simple_bind_s(user_dn.decode('utf-8'), password)
return True
except ldap.LDAPError:
......@@ -248,6 +245,8 @@ class LDAP(object):
current_app.config['LDAP_USER_GROUPS_FIELD']]
result = [re.findall(b'(?:cn=|CN=)(.*?),', group)[0]
for group in groups]
if sys.version_info[0] > 2:
result = [r.decode('utf-8') for r in result]
return result
except ldap.LDAPError as e:
raise LDAPException(self.error(e.args))
......@@ -272,6 +271,8 @@ class LDAP(object):
records[0][1]:
members = records[0][1][
current_app.config['LDAP_GROUP_MEMBERS_FIELD']]
if sys.version_info[0] > 2:
members = [m.decode('utf-8') for m in members]
return members
except ldap.LDAPError as e:
raise LDAPException(self.error(e.args))
......
......@@ -9,7 +9,7 @@ from setuptools import setup
setup(
name='Flask-SimpleLDAP',
version='1.1.2',
version='1.2.0',
url='https://github.com/admiralobvious/flask-simpleldap',
license='MIT',
author='Alexandre Ferland',
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment