class GrapeTokenAuth::OmniAuthSuccessHTML

Constants

SUCCESS_MESSAGE

Attributes

oauth_resource[R]
omniauth_params[R]

Public Class Methods

build(resource_class, auth_hash, omniauth_params) click to toggle source
# File lib/grape_token_auth/omniauth/omniauth_success_html.rb, line 16
def self.build(resource_class, auth_hash, omniauth_params)
  oauth_resource = OmniAuthResource.fetch_or_create(resource_class,
                                                    auth_hash,
                                                    omniauth_params)
  new(oauth_resource, auth_hash, omniauth_params)
end
new(oauth_resource, auth_hash, omniauth_params) click to toggle source
# File lib/grape_token_auth/omniauth/omniauth_success_html.rb, line 10
def initialize(oauth_resource, auth_hash, omniauth_params)
  @oauth_resource  = oauth_resource
  @auth_hash       = auth_hash
  @omniauth_params = omniauth_params
end

Public Instance Methods

auth_origin_url() click to toggle source
# File lib/grape_token_auth/omniauth/omniauth_success_html.rb, line 23
def auth_origin_url
  @omniauth_params['auth_origin_url'] || @omniauth_params[:auth_origin_url]
end
full_redirect_url() click to toggle source
# File lib/grape_token_auth/omniauth/omniauth_success_html.rb, line 32
def full_redirect_url
  "#{auth_origin_url}?#{auth_origin_query_params.to_query}"
end
json_post_data() click to toggle source
# File lib/grape_token_auth/omniauth/omniauth_success_html.rb, line 36
def json_post_data
  success_attributes = { 'message' => SUCCESS_MESSAGE,
                         'config' => omniauth_params['config'] }
  oauth_resource.attributes.merge(success_attributes).to_json
end
window_type() click to toggle source
# File lib/grape_token_auth/omniauth/omniauth_success_html.rb, line 27
def window_type
  @omniauth_params['omniauth_window_type'] ||
    @omniauth_params[:omniauth_window_type]
end

Private Instance Methods

auth_origin_query_params() click to toggle source
# File lib/grape_token_auth/omniauth/omniauth_success_html.rb, line 50
def auth_origin_query_params
  {
    auth_token: oauth_resource.token,
    client_id:  oauth_resource.client_id,
    uid:        oauth_resource.uid,
    expiry:     oauth_resource.expiry,
    config:     config
  }
end
config() click to toggle source
# File lib/grape_token_auth/omniauth/omniauth_success_html.rb, line 46
def config
  omniauth_params['config_name']
end