Class: Opro::Oauth::TestsController

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

Instance Method Summary collapse

Instance Method Details

#createObject



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'app/controllers/opro/oauth/tests_controller.rb', line 26

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

#destroyObject



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'app/controllers/opro/oauth/tests_controller.rb', line 43

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

#indexObject



5
6
7
# File 'app/controllers/opro/oauth/tests_controller.rb', line 5

def index

end

#showObject



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'app/controllers/opro/oauth/tests_controller.rb', line 9

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