Sha256: bf4822c2662d1738ad5d6048ee5fa6d281894738b4bd4e6331633ac52223fd40

Contents?: true

Size: 1.27 KB

Versions: 14

Compression:

Stored size: 1.27 KB

Contents

module Doorkeeper
  class AuthorizationsController < ::Doorkeeper::ApplicationController
    before_filter :authenticate_resource_owner!

    def new
      if pre_auth.authorizable?
        if Doorkeeper::AccessToken.matching_token_for(pre_auth.client, current_resource_owner.id, pre_auth.scopes) || skip_authorization?
          auth = authorization.authorize
          redirect_to auth.redirect_uri
        else
          render :new
        end
      else
        render :error
      end
    end

    def show
    end

    # TODO: Handle raise invalid authorization
    def create
      auth = authorization.authorize

      if auth.redirectable?
        redirect_to auth.redirect_uri
      else
        render :json => auth.body, :status => auth.status
      end
    end

    def destroy
      auth = authorization.deny

      if auth.redirectable?
        redirect_to auth.redirect_uri
      else
        render :json => auth.body, :status => auth.status
      end
    end

  private

    def pre_auth
      @pre_auth ||= OAuth::PreAuthorization.new(Doorkeeper.configuration, server.client_via_uid, params)
    end

    def authorization
      @authorization ||= strategy.request
    end

    def strategy
      @strategy ||= server.authorization_request pre_auth.response_type
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
doorkeeper-1.1.0 app/controllers/doorkeeper/authorizations_controller.rb
doorkeeper-1.0.0 app/controllers/doorkeeper/authorizations_controller.rb
doorkeeper-1.0.0.rc2 app/controllers/doorkeeper/authorizations_controller.rb
doorkeeper-1.0.0.rc1 app/controllers/doorkeeper/authorizations_controller.rb
doorkeeper-0.7.4 app/controllers/doorkeeper/authorizations_controller.rb
doorkeeper-0.7.3 app/controllers/doorkeeper/authorizations_controller.rb
doorkeeper-0.7.2 app/controllers/doorkeeper/authorizations_controller.rb
doorkeeper-0.7.1 app/controllers/doorkeeper/authorizations_controller.rb
doorkeeper-0.7.0 app/controllers/doorkeeper/authorizations_controller.rb
doorkeeper-0.6.7 app/controllers/doorkeeper/authorizations_controller.rb
doorkeeper-0.6.6 app/controllers/doorkeeper/authorizations_controller.rb
doorkeeper-0.6.5 app/controllers/doorkeeper/authorizations_controller.rb
doorkeeper-0.6.4 app/controllers/doorkeeper/authorizations_controller.rb
doorkeeper-0.6.3 app/controllers/doorkeeper/authorizations_controller.rb