Skip to content
Snippets Groups Projects
Verified Commit 70ac63d7 authored by Andrej Shadura's avatar Andrej Shadura
Browse files

Try harder to derive the username from email addresses


Some providers set username or nickname to an email address.
For this reason, first collect the best possible user name we can find,
and only then fix it to match our requirements.

Signed-off-by: Andrej Shadura's avatarAndrej Shadura <andrew.shadura@collabora.co.uk>
parent 75d0aa20
Branches
No related tags found
Loading
......@@ -300,10 +300,19 @@ class Webui::UserController < Webui::WebuiController
return
end
# Try to derive a username from the information available,
# falling back to full name if nothing else works
@derived_username = auth_hash['info']['username'] ||
auth_hash['info']['nickname'] ||
auth_hash['info']['email'].rpartition("@")[0] ||
auth_hash['info']['name'].gsub(' ', '_')
auth_hash['info']['email'] ||
auth_hash['info']['name']
# Some providers set username or nickname to an email address
# Derive the username from the local part of the email address,
# if possible. The full name with spaces replaced by underscores
# is the last resort fallback.
@derived_username = @derived_username.rpartition("@")[0] if @derived_username.include? "@"
@derived_username = @derived_username.gsub(' ', '_')
end
def do_sso_confirm
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment