2018-12-07 23:39:06 +08:00
|
|
|
class Auth::TwitterAuthenticator < Auth::ManagedAuthenticator
|
2013-08-23 14:20:43 +08:00
|
|
|
def name
|
|
|
|
"twitter"
|
|
|
|
end
|
|
|
|
|
2018-07-23 23:51:57 +08:00
|
|
|
def enabled?
|
|
|
|
SiteSetting.enable_twitter_logins
|
|
|
|
end
|
|
|
|
|
2018-07-27 19:28:51 +08:00
|
|
|
def after_authenticate(auth_token, existing_account: nil)
|
2018-12-07 23:39:06 +08:00
|
|
|
# Twitter sends a huge amount of data which we don't need, so ignore it
|
|
|
|
auth_token[:extra] = {}
|
|
|
|
super
|
2013-08-23 14:20:43 +08:00
|
|
|
end
|
|
|
|
|
2013-08-26 09:04:16 +08:00
|
|
|
def register_middleware(omniauth)
|
|
|
|
omniauth.provider :twitter,
|
2017-07-28 09:20:09 +08:00
|
|
|
setup: lambda { |env|
|
|
|
|
strategy = env["omniauth.strategy"]
|
2013-08-26 09:04:16 +08:00
|
|
|
strategy.options[:consumer_key] = SiteSetting.twitter_consumer_key
|
|
|
|
strategy.options[:consumer_secret] = SiteSetting.twitter_consumer_secret
|
|
|
|
}
|
|
|
|
end
|
2013-08-23 14:20:43 +08:00
|
|
|
end
|