Class: GrapeTokenAuth::OmniAuthSuccessHTML

Inherits:
OmniAuthHTMLBase show all
Extended by:
Forwardable
Defined in:
lib/grape_token_auth/omniauth/omniauth_success_html.rb

Constant Summary collapse

SUCCESS_MESSAGE =
'deliverCredentials'

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from OmniAuthHTMLBase

#render_html

Constructor Details

#initialize(oauth_resource, auth_hash, omniauth_params) ⇒ OmniAuthSuccessHTML

Returns a new instance of OmniAuthSuccessHTML.



10
11
12
13
14
# 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

Class Method Details

.build(resource_class, auth_hash, omniauth_params) ⇒ Object



16
17
18
19
20
21
# 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

Instance Method Details

#auth_origin_urlObject



23
24
25
# 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_urlObject



32
33
34
# 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_dataObject



36
37
38
39
40
# 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_typeObject



27
28
29
30
# 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