diff options
author | Marin Jankovski <marin@gitlab.com> | 2014-06-11 17:06:28 +0200 |
---|---|---|
committer | Marin Jankovski <marin@gitlab.com> | 2014-06-11 17:06:28 +0200 |
commit | 314e4736e485ef00092ff7248503b439fac5c490 (patch) | |
tree | c5799ebd6e897cf21f878a04b79061bef0f321b2 /lib | |
parent | d1f3643cbcf35034be71842733d8fe0937474139 (diff) | |
download | gitlab-ce-314e4736e485ef00092ff7248503b439fac5c490.tar.gz |
Strip apostrophe from email generated usernames.
Diffstat (limited to 'lib')
-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! |