Class: OauthClientsController

Inherits:
ApplicationController
  • Object
show all
Includes:
Oauth2::Provider::SslHelper, Oauth2::Provider::TransactionHelper
Defined in:
app/controllers/oauth_clients_controller.rb

Overview

Copyright © 2010 ThoughtWorks Inc. (thoughtworks.com) Licenced under the MIT License (www.opensource.org/licenses/mit-license.php)

Instance Method Summary collapse

Methods included from Oauth2::Provider::TransactionHelper

included

Methods included from Oauth2::Provider::SslHelper

included

Instance Method Details

#createObject



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'app/controllers/oauth_clients_controller.rb', line 36

def create
  @oauth_client = Oauth2::Provider::OauthClient.new(params[:oauth_client])

  respond_to do |format|
    if @oauth_client.save
      flash[:notice] = 'OAuth client was successfully created.'
      format.html { redirect_to :action => 'index' }
      format.xml  { render :xml => @oauth_client, :status => :created, :location => @oauth_client }
    else
      flash.now[:error] = @oauth_client.errors.full_messages
      format.html { render :action => "new" }
      format.xml  { render :xml => @oauth_client.errors, :status => :unprocessable_entity }
    end
  end
end

#destroyObject



69
70
71
72
73
74
75
76
77
78
# File 'app/controllers/oauth_clients_controller.rb', line 69

def destroy
  @oauth_client = Oauth2::Provider::OauthClient.find(params[:id])
  @oauth_client.destroy

  respond_to do |format|
    flash[:notice] = 'OAuth client was successfully deleted.'
    format.html { redirect_to(oauth_clients_url) }
    format.xml  { head :ok }
  end
end

#editObject



32
33
34
# File 'app/controllers/oauth_clients_controller.rb', line 32

def edit
  @oauth_client = Oauth2::Provider::OauthClient.find(params[:id])
end

#indexObject



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

def index
  @oauth_clients = Oauth2::Provider::OauthClient.all.sort{|a, b| a.name.casecmp(b.name)}
  respond_to do |format|
    format.html
    format.xml  { render :xml => @oauth_clients.to_xml(:root => 'oauth_clients', :dasherize => false) }
  end
end

#newObject



28
29
30
# File 'app/controllers/oauth_clients_controller.rb', line 28

def new
  @oauth_client = Oauth2::Provider::OauthClient.new
end

#showObject



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

def show
  @oauth_client = Oauth2::Provider::OauthClient.find(params[:id])
  respond_to do |format|
    format.html
    format.xml  { render :xml => @oauth_client.to_xml(:dasherize => false) }
  end
end

#updateObject



52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'app/controllers/oauth_clients_controller.rb', line 52

def update
  @oauth_client = Oauth2::Provider::OauthClient.find(params[:id])

  respond_to do |format|
    if @oauth_client.update_attributes(params[:oauth_client])
      flash[:notice] = 'OAuth client was successfully updated.'
      format.html { redirect_to :action => 'index' }
      format.xml  { head :ok }
    else
      flash.now[:error] = @oauth_client.errors.full_messages
      format.html { render :action => "edit" }
      format.xml  { render :xml => @oauth_client.errors, :status => :unprocessable_entity }
    end
  end

end