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