Sha256: a193483dbb98f38094928d6b9cfd680c0d313cbf16009aca680f755c7da11351

Contents?: true

Size: 1.69 KB

Versions: 2

Compression:

Stored size: 1.69 KB

Contents

class 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 D:  #{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 => 'OHNO!!! 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.0.3 app/controllers/oauth/tests_controller.rb
opro-0.0.2 app/controllers/oauth/tests_controller.rb