diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2014-06-11 18:59:26 +0000 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2014-06-11 18:59:26 +0000 |
commit | 7edbee6c187460f656134199d8145b7f781f2c09 (patch) | |
tree | 6574cddfa080ca0ed9d4c7582719d85cad252920 | |
parent | 4b6c93c127799d088e16be5028088c0d6f48b578 (diff) | |
parent | 314e4736e485ef00092ff7248503b439fac5c490 (diff) | |
download | gitlab-ce-7edbee6c187460f656134199d8145b7f781f2c09.tar.gz |
Merge branch 'strip_apostrophe_from_email_generated_username' into 'master'
Strip apostrophe from email generated username
Related to #1225
Fixes #1225
-rw-r--r-- | lib/gitlab/ldap/user.rb | 4 | ||||
-rw-r--r-- | lib/gitlab/oauth/user.rb | 4 |
2 files changed, 6 insertions, 2 deletions
diff --git a/lib/gitlab/ldap/user.rb b/lib/gitlab/ldap/user.rb index 01d86430f02..be3fcc4f035 100644 --- a/lib/gitlab/ldap/user.rb +++ b/lib/gitlab/ldap/user.rb @@ -50,7 +50,9 @@ module Gitlab # we look for user by extracting part of their email if !user && email && ldap_conf['allow_username_or_email_login'] uname = email.partition('@').first - user = model.find_by(username: uname) + # Strip apostrophes since they are disallowed as part of username + username = uname.gsub("'", "") + user = model.find_by(username: username) end user diff --git a/lib/gitlab/oauth/user.rb b/lib/gitlab/oauth/user.rb index d154bd8600b..c5be884a895 100644 --- a/lib/gitlab/oauth/user.rb +++ b/lib/gitlab/oauth/user.rb @@ -39,7 +39,9 @@ module Gitlab # So we use part of email as username for new user # For LDAP, username is already set to the user's # uid/userid/sAMAccountName. - user.username = email.match(/^[^@]*/)[0] + email_username = email.match(/^[^@]*/)[0] + # Strip apostrophes since they are disallowed as part of username + user.username = email_username.gsub("'", "") end user.save! |