Class: OauthClientsController

Inherits:
ApplicationController
  • Object
show all
Defined in:
app/controllers/oauth_clients_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



20
21
22
23
24
25
26
27
28
# File 'app/controllers/oauth_clients_controller.rb', line 20

def create
  attrs = {:id           => params[:id],
           :secret       => params[:secret],
           :display_name => params[:display_name],
           :link         => params[:link]}

  client = Rack::OAuth2::Server.register(attrs)
  render :json => client.to_json
end

#destroyObject



30
31
32
33
34
35
36
37
38
39
# File 'app/controllers/oauth_clients_controller.rb', line 30

def destroy
  client = Rack::OAuth2::Server.get_client(params[:id])

  if client
    client.destroy
    render :nothing => true, :status => :accepted
  else
    render :nothing => true, :status => :not_found
  end
end

#indexObject

oauth_required :only => [:create, :destroy]



4
5
6
7
# File 'app/controllers/oauth_clients_controller.rb', line 4

def index
  clients = Rack::OAuth2::Server::Client.all.collect{|x| x.parse_notes; x}
  render :json => clients.to_json
end

#showObject



9
10
11
12
13
14
15
16
17
18
# File 'app/controllers/oauth_clients_controller.rb', line 9

def show
  client = Rack::OAuth2::Server.get_client(params[:id])

  if client
    client.parse_notes
    render :json => client.to_json
  else
    render :nothing => true, :status => :not_found
  end
end