Class: OmniAuth::Strategies::OAuth2

Inherits:
Object
  • Object
show all
Defined in:
lib/patch/omniauth-oauth2.rb

Direct Known Subclasses

GeekPark, Synced, WeChat, WeChatService, Weibo

Instance Method Summary collapse

Instance Method Details

#callback_phaseObject

rubocop:disable AbcSize, CyclomaticComplexity, MethodLength, PerceivedComplexity



2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/patch/omniauth-oauth2.rb', line 2

def callback_phase # rubocop:disable AbcSize, CyclomaticComplexity, MethodLength, PerceivedComplexity
  error = request.params["error_reason"] || request.params["error"]
  if error
    fail!(error, CallbackError.new(request.params["error"], request.params["error_description"] || request.params["error_reason"], request.params["error_uri"]))
  elsif !options.provider_ignores_state && (request.params["state"].to_s.empty? || request.params["state"] != session.delete("omniauth.state"))
    fail!(:csrf_detected, CallbackError.new(:csrf_detected, "CSRF detected"))
  else
    self.access_token = build_access_token
    fail!(:token_expired, CallbackError.new(:token_expired,'Token has expired, refresh and try again.')) if access_token.expired?
    super
  end
rescue ::OAuth2::Error, CallbackError => e
  fail!(:invalid_credentials, e)
rescue ::Timeout::Error, ::Errno::ETIMEDOUT => e
  fail!(:timeout, e)
rescue ::SocketError => e
  fail!(:failed_to_connect, e)
end

#callback_urlObject



21
22
23
# File 'lib/patch/omniauth-oauth2.rb', line 21

def callback_url
  full_host + script_name + callback_path
end