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