Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add email_verified and is_private_email #67

Merged
merged 1 commit into from
Sep 26, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions lib/omniauth/strategies/apple.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,17 @@ class Apple < OmniAuth::Strategies::OAuth2

uid { id_info['sub'] }

# Documentation on parameters
# https://developer.apple.com/documentation/sign_in_with_apple/sign_in_with_apple_rest_api/authenticating_users_with_sign_in_with_apple
info do
prune!(
sub: id_info['sub'],
email: email,
first_name: first_name,
last_name: last_name,
name: (first_name || last_name) ? [first_name, last_name].join(' ') : email,
email_verified: email_verified,
is_private_email: is_private_email
)
end

Expand All @@ -38,6 +42,16 @@ def client
::OAuth2::Client.new(client_id, client_secret, deep_symbolize(options.client_options))
end

def email_verified
value = id_info['email_verified']
value == true || value == "true"
end

def is_private_email
value = id_info['is_private_email']
value == true || value == "true"
end

def authorize_params
super.merge(nonce: new_nonce)
end
Expand Down