Strip apostrophe from email generated usernames.

This commit is contained in:
Marin Jankovski 2014-06-11 17:06:28 +02:00
parent d1f3643cbc
commit 314e4736e4
2 changed files with 6 additions and 2 deletions

View File

@ -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

View File

@ -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!