Commit 314e4736 authored by Marin Jankovski's avatar Marin Jankovski

Strip apostrophe from email generated usernames.

parent d1f3643c
......@@ -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