* Add Providers(.available|.enabled|.enabled?) * Add provider_sidebar partial * Add providers_signup_modal partial and Providers.sign_in_url * Use path helpers * Add providers_nav_menu partial * Add providers_registration_form partial * Generalize users/additional_authentication * Refactor sign_in_path and authentication_path * Add .official_name and fix specs * Preload authentication providers correctly and use less Ruby magic * Put require_dependency in the correct place
39 lines
904 B
Ruby
39 lines
904 B
Ruby
module Authentication
|
|
module Providers
|
|
# GitHub authentication provider, uses omniauth-github as backend
|
|
class Github < Provider
|
|
OFFICIAL_NAME = "GitHub".freeze
|
|
CREATED_AT_FIELD = "github_created_at".freeze
|
|
USERNAME_FIELD = "github_username".freeze
|
|
|
|
def new_user_data
|
|
name = raw_info.name.presence || info.name
|
|
|
|
{
|
|
email: info.email.to_s,
|
|
github_created_at: raw_info.created_at,
|
|
github_username: info.nickname,
|
|
name: name,
|
|
remote_profile_image_url: info.image.to_s
|
|
}
|
|
end
|
|
|
|
def existing_user_data
|
|
{
|
|
github_created_at: raw_info.created_at,
|
|
github_username: info.nickname
|
|
}
|
|
end
|
|
|
|
def self.official_name
|
|
OFFICIAL_NAME
|
|
end
|
|
|
|
protected
|
|
|
|
def cleanup_payload(auth_payload)
|
|
auth_payload
|
|
end
|
|
end
|
|
end
|
|
end
|