2019-05-02 17:17:27 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-11-28 09:49:24 -06:00
|
|
|
class Auth::FacebookAuthenticator < Auth::ManagedAuthenticator
|
2013-08-23 01:20:43 -05:00
|
|
|
|
2018-08-09 10:29:02 -05:00
|
|
|
AVATAR_SIZE ||= 480
|
2016-09-27 23:38:41 -05:00
|
|
|
|
2013-08-23 01:20:43 -05:00
|
|
|
def name
|
|
|
|
"facebook"
|
|
|
|
end
|
|
|
|
|
2018-07-23 10:51:57 -05:00
|
|
|
def enabled?
|
|
|
|
SiteSetting.enable_facebook_logins
|
|
|
|
end
|
|
|
|
|
2013-08-25 20:04:16 -05:00
|
|
|
def register_middleware(omniauth)
|
|
|
|
omniauth.provider :facebook,
|
|
|
|
setup: lambda { |env|
|
|
|
|
strategy = env["omniauth.strategy"]
|
|
|
|
strategy.options[:client_id] = SiteSetting.facebook_app_id
|
|
|
|
strategy.options[:client_secret] = SiteSetting.facebook_app_secret
|
2018-11-28 09:49:24 -06:00
|
|
|
strategy.options[:info_fields] = 'name,first_name,last_name,email'
|
|
|
|
strategy.options[:image_size] = { width: AVATAR_SIZE, height: AVATAR_SIZE }
|
|
|
|
strategy.options[:secure_image_url] = true
|
2013-08-25 20:04:16 -05:00
|
|
|
},
|
|
|
|
scope: "email"
|
|
|
|
end
|
|
|
|
|
2013-08-23 01:20:43 -05:00
|
|
|
end
|