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 = ClientApplication.new
 
  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
 
  24       render :action => "new"
 
  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
 
  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
 
  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
 
  48       render :action => "edit"
 
  50   rescue ActiveRecord::RecordNotFound
 
  51     @type = "client application"
 
  52     render :action => "not_found", :status => :not_found
 
  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
 
  67   def application_params
 
  68     params.require(:client_application).permit(:name, :url, :callback_url, :support_url, ClientApplication.all_permissions)