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