FIX: Allow signup when auth provider supplies no email

This commit is contained in:
David Taylor 2020-07-10 17:56:33 +01:00
parent 275b748016
commit fbf29443bd
No known key found for this signature in database
GPG Key ID: 46904C18B1D3F434
2 changed files with 38 additions and 1 deletions

View File

@ -40,7 +40,7 @@ class UserAuthenticator
def authenticated?
return false if !@auth_result
return false if @auth_result.email.downcase != @user.email.downcase
return false if @auth_result&.email&.downcase != @user.email.downcase
return false if @auth_result.email_valid != true # strong check for truth, in case we have another object type
true
end

View File

@ -1056,6 +1056,43 @@ describe UsersController do
end
end
context "with no email in the auth payload" do
before do
OmniAuth.config.test_mode = true
OmniAuth.config.mock_auth[:twitter] = OmniAuth::AuthHash.new(
provider: 'twitter',
uid: '123545',
info: OmniAuth::AuthHash::InfoHash.new(
nickname: "testosama",
name: "Osama Test"
)
)
Rails.application.env_config["omniauth.auth"] = OmniAuth.config.mock_auth[:twitter]
SiteSetting.enable_twitter_logins = true
get "/auth/twitter/callback.json"
end
after do
Rails.application.env_config["omniauth.auth"] = OmniAuth.config.mock_auth[:twitter] = nil
OmniAuth.config.test_mode = false
end
it "will create the user successfully" do
Rails.application.env_config["omniauth.auth"].info.email = nil
post "/u.json", params: {
name: "Test Osama",
username: "testosama",
password: "strongpassword",
email: "osama@mail.com"
}
expect(response.status).to eq(200)
json = response.parsed_body
expect(json['success']).to eq(true)
end
end
end
it "creates user successfully but doesn't activate the account" do