2018-12-07 10:39:06 -05:00
|
|
|
class Auth::TwitterAuthenticator < Auth::ManagedAuthenticator
|
2013-08-23 02:20:43 -04:00
|
|
|
def name
|
|
|
|
"twitter"
|
|
|
|
end
|
|
|
|
|
2018-07-23 11:51:57 -04:00
|
|
|
def enabled?
|
|
|
|
SiteSetting.enable_twitter_logins
|
|
|
|
end
|
|
|
|
|
2018-07-27 07:28:51 -04:00
|
|
|
def after_authenticate(auth_token, existing_account: nil)
|
2018-12-07 10:39:06 -05:00
|
|
|
# Twitter sends a huge amount of data which we don't need, so ignore it
|
|
|
|
auth_token[:extra] = {}
|
|
|
|
super
|
2013-08-23 02:20:43 -04:00
|
|
|
end
|
|
|
|
|
2013-08-25 21:04:16 -04:00
|
|
|
def register_middleware(omniauth)
|
|
|
|
omniauth.provider :twitter,
|
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[:consumer_key] = SiteSetting.twitter_consumer_key
|
|
|
|
strategy.options[:consumer_secret] = SiteSetting.twitter_consumer_secret
|
|
|
|
}
|
|
|
|
end
|
2013-08-23 02:20:43 -04:00
|
|
|
end
|