]> git.openstreetmap.org Git - rails.git/blob - app/controllers/oauth_clients_controller.rb
Prefer keyword arguments when method has optional boolean arguments
[rails.git] / app / controllers / oauth_clients_controller.rb
1 class OauthClientsController < ApplicationController
2   layout "site"
3
4   before_action :authorize_web
5   before_action :set_locale
6
7   authorize_resource :class => ClientApplication
8
9   def index
10     @client_applications = current_user.client_applications
11     @tokens = current_user.oauth_tokens.authorized
12   end
13
14   def new
15     @client_application = ClientApplication.new
16   end
17
18   def create
19     @client_application = current_user.client_applications.build(application_params)
20     if @client_application.save
21       flash[:notice] = t "oauth_clients.create.flash"
22       redirect_to :action => "show", :id => @client_application.id
23     else
24       render :action => "new"
25     end
26   end
27
28   def show
29     @client_application = current_user.client_applications.find(params[:id])
30   rescue ActiveRecord::RecordNotFound
31     @type = "client application"
32     render :action => "not_found", :status => :not_found
33   end
34
35   def edit
36     @client_application = current_user.client_applications.find(params[:id])
37   rescue ActiveRecord::RecordNotFound
38     @type = "client application"
39     render :action => "not_found", :status => :not_found
40   end
41
42   def update
43     @client_application = current_user.client_applications.find(params[:id])
44     if @client_application.update(application_params)
45       flash[:notice] = t "oauth_clients.update.flash"
46       redirect_to :action => "show", :id => @client_application.id
47     else
48       render :action => "edit"
49     end
50   rescue ActiveRecord::RecordNotFound
51     @type = "client application"
52     render :action => "not_found", :status => :not_found
53   end
54
55   def destroy
56     @client_application = current_user.client_applications.find(params[:id])
57     @client_application.destroy
58     flash[:notice] = t "oauth_clients.destroy.flash"
59     redirect_to :action => "index"
60   rescue ActiveRecord::RecordNotFound
61     @type = "client application"
62     render :action => "not_found", :status => :not_found
63   end
64
65   private
66
67   def application_params
68     params.require(:client_application).permit(:name, :url, :callback_url, :support_url, ClientApplication.all_permissions)
69   end
70 end