Skip to content

Commit

Permalink
Add email_verified and is_private_email
Browse files Browse the repository at this point in the history
  • Loading branch information
wilg committed Feb 22, 2021
1 parent a9b2b78 commit d513856
Showing 1 changed file with 14 additions and 0 deletions.
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

0 comments on commit d513856

Please sign in to comment.