class OmniAuth::Strategies::Mastodon
Constants
- DEFAULT_SCOPE
Public Instance Methods
callback_phase()
click to toggle source
Calls superclass method
# File lib/omniauth/strategies/mastodon.rb, line 42 def callback_phase set_options_from_identifier super end
callback_url()
click to toggle source
# File lib/omniauth/strategies/mastodon.rb, line 51 def callback_url full_host + script_name + callback_path end
raw_info()
click to toggle source
# File lib/omniauth/strategies/mastodon.rb, line 47 def raw_info @raw_info ||= access_token.get('api/v1/accounts/verify_credentials').parsed end
request_phase()
click to toggle source
Before we can redirect the user to authorize access, we must know where the user is from If the identifier param is not already present, a form will be shown for entering it
# File lib/omniauth/strategies/mastodon.rb, line 37 def request_phase # identifier ? start_oauth : get_identifier start_oauth end
Private Instance Methods
identifier()
click to toggle source
# File lib/omniauth/strategies/mastodon.rb, line 87 def identifier i = options.identifier || request.params['identifier'] || (env['omniauth.params'].is_a?(Hash) ? env['omniauth.params']['identifier'] : nil) || session[:identifier] i = i.downcase.strip unless i.nil? i = nil if i == '' session[:identifier] = i unless i.nil? i end
set_options_from_identifier()
click to toggle source
# File lib/omniauth/strategies/mastodon.rb, line 95 def set_options_from_identifier # username, domain = identifier.split('@') domain = options[:domain] # client_id, client_secret = options.credentials.call(domain, callback_url) # options.identifier = identifier # options.client_options[:site] = "http://#{domain}" options.client_options[:site] = domain # options.client_id = client_id # options.client_secret = client_secret end
start_oauth()
click to toggle source
def locale
loc = request.params['locale'] || session[:omniauth_login_locale] || I18n.default_locale loc = :en unless I18n.locale_available?(loc) loc
end
# File lib/omniauth/strategies/mastodon.rb, line 82 def start_oauth set_options_from_identifier redirect client.auth_code.authorize_url({:redirect_uri => callback_url}.merge(authorize_params)) end