Class: OmniAuth::Strategies::Gorgias

Inherits:
OAuth2
  • Object
show all
Defined in:
lib/omniauth/strategies/gorgias.rb

Instance Method Summary collapse

Instance Method Details

#accountObject



51
52
53
# File 'lib/omniauth/strategies/gorgias.rb', line 51

def 
  @account ||= request.params['account']
end

#account_present?Boolean

Returns:

  • (Boolean)


55
56
57
# File 'lib/omniauth/strategies/gorgias.rb', line 55

def 
  !!( =~ /\A[a-z0-9][a-z0-9\-]*\z/i)
end

#authorize_paramsObject



31
32
33
34
35
36
# File 'lib/omniauth/strategies/gorgias.rb', line 31

def authorize_params
  nonce = SecureRandom.hex(16)
  session['omniauth.nonce'] = nonce

  super.merge(nonce: nonce)
end

#callback_urlObject



38
39
40
# File 'lib/omniauth/strategies/gorgias.rb', line 38

def callback_url
  full_host + script_name + callback_path + "?account=#{}"
end

#request_phaseObject



20
21
22
23
24
25
26
27
# File 'lib/omniauth/strategies/gorgias.rb', line 20

def request_phase
  return fail!(:account_missing) unless 

  options[:scope] ||= 'openid'
  options[:response_type] ||= 'code'

  super
end

#token_paramsObject



42
43
44
45
46
47
48
49
# File 'lib/omniauth/strategies/gorgias.rb', line 42

def token_params
  super.merge(
    headers: {
      'Authorization' => "Basic #{Base64.strict_encode64("#{options.client_id}:#{options.client_secret}")}"
    },
    redirect_uri: callback_url
  )
end