* Add Authentication providers * Making strides on refactoring * New usr from Twitter * Existing Twitter user * Existing user Github * Test skip_confirmation! * Refactor a bit and add simplecov groups * Test user already logged in * Rename to Authentication::Authenticator * Refactor to a common class * Add existing user test for twitter login * Refactor global handler * Fix spec and comment Twitter provider * Update comments and strategy TODO * Move providers loading code to Authentication::Providers * add SubclassResponsibility error * Use delegation
34 lines
804 B
Ruby
34 lines
804 B
Ruby
module Authentication
|
|
module Providers
|
|
# GitHub authentication provider, uses omniauth-github as backend
|
|
class Github < Provider
|
|
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
|
|
|
|
protected
|
|
|
|
def cleanup_payload(auth_payload)
|
|
auth_payload
|
|
end
|
|
end
|
|
end
|
|
end
|