Class: Opro::Oauth::AuthController

Inherits:
OproController
  • Object
show all
Defined in:
app/controllers/opro/oauth/auth_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject

:ask_user! is called before creating a new authorization, this allows us to redirect



15
16
17
18
19
20
21
22
23
24
25
26
# File 'app/controllers/opro/oauth/auth_controller.rb', line 15

def create
  # find or create an auth_grant for a given user
  application  =   Opro::Oauth::ClientApp.find_by_app_id(params[:client_id])
  auth_grant =   Opro::Oauth::AuthGrant.where( :user_id => current_user.id, :application_id => application.id).first
  auth_grant ||= Opro::Oauth::AuthGrant.create(:user => current_user,       :application => application)


  # add permission changes if there are any
  auth_grant.update_attributes(:permissions => params[:permissions]) if auth_grant.permissions != params[:permissions]

  redirect_to auth_grant.redirect_uri_for(params[:redirect_uri], params[:state])
end

#newObject



6
7
8
9
10
# File 'app/controllers/opro/oauth/auth_controller.rb', line 6

def new
  @redirect_uri = params[:redirect_uri]
  @client_app   = Opro::Oauth::ClientApp.find_by_app_id(params[:client_id])
  @scopes       = scope_from_params(params)
end