summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorMarin Jankovski <marin@gitlab.com>2014-06-11 17:06:28 +0200
committerMarin Jankovski <marin@gitlab.com>2014-06-11 17:06:28 +0200
commit314e4736e485ef00092ff7248503b439fac5c490 (patch)
treec5799ebd6e897cf21f878a04b79061bef0f321b2 /lib
parentd1f3643cbcf35034be71842733d8fe0937474139 (diff)
downloadgitlab-ce-314e4736e485ef00092ff7248503b439fac5c490.tar.gz
Strip apostrophe from email generated usernames.
Diffstat (limited to 'lib')
-rw-r--r--lib/gitlab/ldap/user.rb4
-rw-r--r--lib/gitlab/oauth/user.rb4
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!