Module: Authifer::OAuthHelper

Defined in:
lib/authifer/oauth_helper.rb

Instance Method Summary collapse

Instance Method Details

#handle_oauthObject



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/authifer/oauth_helper.rb', line 11

def handle_oauth
  if oauth2.redirect?
    redirect oauth2.redirect_uri, oauth2.response_status
  end

  headers oauth2.response_headers
  status  oauth2.response_status

  if body = oauth2.response_body
    body
  elsif oauth2.valid?
    erb :authorize, locals: { authorization_request: oauth2 }
  else
    raise "Error Will Robinson"
  end
end

#oauth2Object



7
8
9
# File 'lib/authifer/oauth_helper.rb', line 7

def oauth2
  @oauth2 ||= Songkick::OAuth2::Provider.parse(resource_owner, env)
end

#resource_ownerObject



3
4
5
# File 'lib/authifer/oauth_helper.rb', line 3

def resource_owner
  @resource_owner ||= current_user.persisted? ? current_user : :implicit
end