提交 262276c5 编写于 作者: J Jan-Willem van der Meer

Ensure oath callbacks without a nickname work (google)

上级 5801d520
......@@ -86,6 +86,7 @@ module Gitlab
end
def username
return unless auth.info.respond_to?(:nickname)
auth.info.nickname.to_s.force_encoding("utf-8")
end
......
......@@ -68,5 +68,17 @@ describe Gitlab::OAuth::User do
user = gl_auth.create(auth)
expect(user.email).to_not be_empty
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
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册