Skip to content
Snippets Groups Projects
Commit 262276c5 authored by Jan-Willem van der Meer's avatar Jan-Willem van der Meer
Browse files

Ensure oath callbacks without a nickname work (google)

parent 5801d520
No related branches found
No related tags found
No related merge requests found
Loading
@@ -86,6 +86,7 @@ module Gitlab
Loading
@@ -86,6 +86,7 @@ module Gitlab
end end
   
def username def username
return unless auth.info.respond_to?(:nickname)
auth.info.nickname.to_s.force_encoding("utf-8") auth.info.nickname.to_s.force_encoding("utf-8")
end end
   
Loading
Loading
Loading
@@ -68,5 +68,17 @@ describe Gitlab::OAuth::User do
Loading
@@ -68,5 +68,17 @@ describe Gitlab::OAuth::User do
user = gl_auth.create(auth) user = gl_auth.create(auth)
expect(user.email).to_not be_empty expect(user.email).to_not be_empty
end end
it 'generates a username if non provided (google)' do
info = double(
uid: 'my-uid',
name: 'John',
email: 'john@example.com'
)
auth = double(info: info, provider: 'my-provider')
user = gl_auth.create(auth)
expect(user.username).to eql 'john'
end
end end
end end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment