diff --git a/rhodecode/lib/auth.py b/rhodecode/lib/auth.py --- a/rhodecode/lib/auth.py +++ b/rhodecode/lib/auth.py @@ -103,6 +103,13 @@ def authfunc(environ, username, password else: + + #since ldap is searching in case insensitive check if this user is still + #not in our system + username = username.lower() + if user_model.get_by_username(username, cache=False) is not None: + return False + from rhodecode.model.settings import SettingsModel ldap_settings = SettingsModel().get_ldap_settings() @@ -110,6 +117,7 @@ def authfunc(environ, username, password # FALLBACK TO LDAP AUTH IN ENABLE #====================================================================== if ldap_settings.get('ldap_active', False): + kwargs = { 'server':ldap_settings.get('ldap_host', ''), 'base_dn':ldap_settings.get('ldap_base_dn', ''), @@ -214,8 +222,8 @@ def fill_perms(user): #default global default_global_perms = sa.query(UserToPerm)\ - .filter(UserToPerm.user == sa.query(User).filter(User.username == - 'default').one()) + .filter(UserToPerm.user == sa.query(User)\ + .filter(User.username == 'default').one()) for perm in default_global_perms: user.permissions['global'].add(perm.permission.permission_name) diff --git a/rhodecode/model/forms.py b/rhodecode/model/forms.py --- a/rhodecode/model/forms.py +++ b/rhodecode/model/forms.py @@ -67,7 +67,7 @@ def ValidUsername(edit, old_data): old_un = UserModel().get(old_data.get('user_id')).username if old_un != value or not edit: - if UserModel().get_by_username(value, cache=False): + if UserModel().get_by_username(value.lower(), cache=False): raise formencode.Invalid(_('This username already exists') , value, state) @@ -244,6 +244,8 @@ class ValidPath(formencode.validators.Fa def UniqSystemEmail(old_data): class _UniqSystemEmail(formencode.validators.FancyValidator): def to_python(self, value, state): + value = value.lower() + #TODO:write test for MixedCase scenarios if old_data.get('email') != value: sa = meta.Session() try: @@ -260,6 +262,7 @@ def UniqSystemEmail(old_data): class ValidSystemEmail(formencode.validators.FancyValidator): def to_python(self, value, state): + value = value.lower() sa = meta.Session try: user = sa.query(User).filter(User.email == value).scalar()