Class: Auth::TwitterAuthenticator

Inherits:
ManagedAuthenticator show all
Defined in:
lib/auth/twitter_authenticator.rb

Instance Method Summary collapse

Methods inherited from ManagedAuthenticator

#after_create_account, #always_update_user_email?, #can_connect_existing_user?, #can_revoke?, #description_for_auth_hash, #description_for_user, #find_user_by_email, #find_user_by_username, #is_managed?, #match_by_email, #match_by_username, #retrieve_avatar, #retrieve_profile, #revoke

Methods inherited from Authenticator

#after_create_account, #can_connect_existing_user?, #can_revoke?, #description_for_auth_hash, #description_for_user, #provides_groups?, #revoke

Instance Method Details

#after_authenticate(auth_token, existing_account: nil) ⇒ Object



12
13
14
15
16
# File 'lib/auth/twitter_authenticator.rb', line 12

def after_authenticate(auth_token, existing_account: nil)
  # Twitter sends a huge amount of data which we don't need, so ignore it
  auth_token[:extra] = {}
  super
end

#enabled?Boolean

Returns:

  • (Boolean)


8
9
10
# File 'lib/auth/twitter_authenticator.rb', line 8

def enabled?
  SiteSetting.enable_twitter_logins
end

#nameObject



4
5
6
# File 'lib/auth/twitter_authenticator.rb', line 4

def name
  "twitter"
end

#primary_email_verified?(auth_token) ⇒ Boolean

Returns:

  • (Boolean)


30
31
32
# File 'lib/auth/twitter_authenticator.rb', line 30

def primary_email_verified?(auth_token)
  true
end

#register_middleware(omniauth) ⇒ Object



18
19
20
21
22
23
24
25
26
# File 'lib/auth/twitter_authenticator.rb', line 18

def register_middleware(omniauth)
  omniauth.provider :twitter,
                    setup:
                      lambda { |env|
                        strategy = env["omniauth.strategy"]
                        strategy.options[:consumer_key] = SiteSetting.twitter_consumer_key
                        strategy.options[:consumer_secret] = SiteSetting.twitter_consumer_secret
                      }
end