1 class OauthClientsController < ApplicationController
4 before_action :authorize_web
5 before_action :set_locale
7 authorize_resource :class => ClientApplication
10 @client_applications = current_user.client_applications
11 @tokens = current_user.oauth_tokens.authorized
15 @client_application = current_user.client_applications.find(params[:id])
16 rescue ActiveRecord::RecordNotFound
17 @type = "client application"
18 render :action => "not_found", :status => :not_found
22 if Settings.oauth_10_registration
23 @client_application = ClientApplication.new
25 flash[:error] = t ".disabled"
26 redirect_to :action => "index"
31 @client_application = current_user.client_applications.find(params[:id])
32 rescue ActiveRecord::RecordNotFound
33 @type = "client application"
34 render :action => "not_found", :status => :not_found
38 @client_application = current_user.client_applications.build(application_params)
39 if @client_application.save
40 flash[:notice] = t ".flash"
41 redirect_to :action => "show", :id => @client_application.id
43 render :action => "new"
48 @client_application = current_user.client_applications.find(params[:id])
49 if @client_application.update(application_params)
50 flash[:notice] = t ".flash"
51 redirect_to :action => "show", :id => @client_application.id
53 render :action => "edit"
55 rescue ActiveRecord::RecordNotFound
56 @type = "client application"
57 render :action => "not_found", :status => :not_found
61 @client_application = current_user.client_applications.find(params[:id])
62 @client_application.destroy
63 flash[:notice] = t ".flash"
64 redirect_to :action => "index"
65 rescue ActiveRecord::RecordNotFound
66 @type = "client application"
67 render :action => "not_found", :status => :not_found
72 def application_params
73 params.require(:client_application).permit(:name, :url, :callback_url, :support_url, ClientApplication.all_permissions)