Skip to content

Commit

Permalink
Merge pull request #2415 from ckan/2415-uppercase-emails-on-user-invite
Browse files Browse the repository at this point in the history
Allow uppercase letters in local part of email when sending user invitations
  • Loading branch information
joetsoi committed Jul 16, 2015
2 parents 716fbad + 31b00b3 commit db19a58
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion ckan/logic/action/create.py
Expand Up @@ -1106,7 +1106,7 @@ def user_invite(context, data_dict):

def _get_random_username_from_email(email):
localpart = email.split('@')[0]
cleaned_localpart = re.sub(r'[^\w]', '-', localpart)
cleaned_localpart = re.sub(r'[^\w]', '-', localpart).lower()

# if we can't create a unique user name within this many attempts
# then something else is probably wrong and we should give up
Expand Down
6 changes: 6 additions & 0 deletions ckan/tests/logic/action/test_create.py
Expand Up @@ -75,6 +75,12 @@ def test_requires_role(self, _):
def test_requires_group_id(self, _):
self._invite_user_to_group(group={'id': None})

@mock.patch('ckan.lib.mailer.send_invite')
def test_user_name_lowercase_when_email_is_uppercase(self, _):
invited_user = self._invite_user_to_group(email='Maria@example.com')

assert_equals(invited_user.name.split('-')[0], 'maria')

def _invite_user_to_group(self, email='user@email.com',
group=None, role='member'):
user = factories.User()
Expand Down

0 comments on commit db19a58

Please sign in to comment.