Commit 7edbee6c authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Merge branch 'strip_apostrophe_from_email_generated_username' into 'master'

Strip apostrophe from email generated username

Related to #1225
Fixes #1225
parents 4b6c93c1 314e4736
......@@ -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
......
......@@ -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!
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment