Skip to content

Commit 537aac3

Browse files
authored
Merge pull request #2584 from mroderick/fix/blank-email-validation
fix: handle blank email from GitHub OAuth
2 parents 5e4ea93 + b4fce89 commit 537aac3

2 files changed

Lines changed: 10 additions & 2 deletions

File tree

app/controllers/auth_services_controller.rb

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,15 @@ def create
2626

2727
finish_registration || redirect_to(referer_or_dashboard_path)
2828
else
29-
member = Member.find_by(email: omnihash[:info][:email])
30-
member ||= Member.new(email: omnihash[:info][:email])
29+
email = omnihash[:info][:email].to_s.strip
30+
31+
if email.blank?
32+
flash[:error] = I18n.t('notifications.email_missing_from_provider')
33+
return redirect_to root_url
34+
end
35+
36+
member = Member.find_by(email:)
37+
member ||= Member.new(email:)
3138

3239
member.name ||= omnihash[:info][:name]&.split(' ')&.first || ''
3340
member.surname ||= omnihash[:info][:name]&.split(' ')&.drop(1)&.join(' ') || ''

config/locales/en.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,7 @@ en:
201201
not_logged_in: "You must be logged in to access this page."
202202
signing_up: "Thanks for signing up. Please fill in your details to complete the registration process."
203203
authentication_error: "Authentication failed. Please try again."
204+
email_missing_from_provider: "We could not retrieve your email address from GitHub. Please make sure your GitHub account has a public email address and try again."
204205
navigation:
205206
dashboard: "Dashboard"
206207
code_of_conduct: "Code of Conduct"

0 commit comments

Comments
 (0)