]> git.openstreetmap.org Git - rails.git/blob - vendor/plugins/oauth-plugin/generators/oauth_provider/templates/clients_controller.rb
Merge 16110:16487 from trunk.
[rails.git] / vendor / plugins / oauth-plugin / generators / oauth_provider / templates / clients_controller.rb
1 class OauthClientsController < ApplicationController
2   before_filter :login_required
3   
4   def index
5     @client_applications = current_user.client_applications
6     @tokens = current_user.tokens.find :all, :conditions => 'oauth_tokens.invalidated_at is null and oauth_tokens.authorized_at is not null'
7   end
8
9   def new
10     @client_application = ClientApplication.new
11   end
12
13   def create
14     @client_application = current_user.client_applications.build(params[:client_application])
15     if @client_application.save
16       flash[:notice] = "Registered the information successfully"
17       redirect_to :action => "show", :id => @client_application.id
18     else
19       render :action => "new"
20     end
21   end
22   
23   def show
24     @client_application = current_user.client_applications.find(params[:id])
25   end
26
27   def edit
28     @client_application = current_user.client_applications.find(params[:id])
29   end
30   
31   def update
32     @client_application = current_user.client_applications.find(params[:id])
33     if @client_application.update_attributes(params[:client_application])
34       flash[:notice] = "Updated the client information successfully"
35       redirect_to :action => "show", :id => @client_application.id
36     else
37       render :action => "edit"
38     end
39   end
40
41   def destroy
42     @client_application = current_user.client_applications.find(params[:id])
43     @client_application.destroy
44     flash[:notice] = "Destroyed the client application registration"
45     redirect_to :action => "index"
46   end
47 end