Sha256: 40627c8a777310e0d01e348ee54d62acab6a725065aac1dfc0f4443af11f7ce8

Contents?: true

Size: 1.7 KB

Versions: 2

Compression:

Stored size: 1.7 KB

Contents

class Opro::Oauth::TestsController < OproController
  allow_oauth!
  disallow_oauth! :only => [:destroy]

  def index

  end

  def show
    result = if valid_oauth?
      {:status => 200, :message => 'OAuth worked!', :params => params, :user_id => oauth_user.id }
    else
      {:status => :unauthorized, :message => "OAuth did not work :(  #{generate_oauth_error_message!}", :params => params}
    end

    respond_to do |format|
      format.html do
        render :text => result.to_json,   :status => result[:status], :layout => true
      end
      format.json do
        render :json => result, :status => result[:status]
      end
    end
  end

  def create
    result = if valid_oauth?
      {:status => 200, :message => 'OAuth worked!', :params => params, :user_id => oauth_user.id }
    else
      {:status => :unauthorized, :message => "OAuth did not work :(  #{generate_oauth_error_message!}", :params => params}
    end

    respond_to do |format|
      format.html do
        render :text => result.to_json,   :status => result[:status], :layout => true
      end
      format.json do
        render :json => result, :status => result[:status]
      end
    end
  end

  def destroy
    result = if valid_oauth?
      {:status => 200, :message => 'OH NO!!! OAuth is disabled on this action; this is bad', :params => params}
    else
      {:status => :unauthorized, :message => "OAuth is disabled on this action; this is the correct result!", :params => params}
    end

    respond_to do |format|
      format.html do
        render :text => result.to_json,   :status => result[:status], :layout => true
      end
      format.json do
        render :json => result, :status => result[:status]
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
opro-0.4.2 app/controllers/opro/oauth/tests_controller.rb
opro-0.4.1 app/controllers/opro/oauth/tests_controller.rb