diff options
author | Valery Sizov <valery@gitlab.com> | 2015-01-18 02:37:27 +0300 |
---|---|---|
committer | Valery Sizov <valery@gitlab.com> | 2015-01-18 02:40:09 +0300 |
commit | 20028523b5a2969b70a1fde9468c434b78f916ea (patch) | |
tree | f09290ba2943c70c1f961b24122eb685f5a7132a /app/controllers | |
parent | ada6c6080b2fa0d63003f8b29b5c32195254906d (diff) |
Application admin scaffold
Diffstat (limited to 'app/controllers')
-rw-r--r-- | app/controllers/admin/applications_controller.rb | 52 | ||||
-rw-r--r-- | app/controllers/oauth/applications_controller.rb | 6 |
2 files changed, 54 insertions, 4 deletions
diff --git a/app/controllers/admin/applications_controller.rb b/app/controllers/admin/applications_controller.rb new file mode 100644 index 00000000000..cba19184dba --- /dev/null +++ b/app/controllers/admin/applications_controller.rb @@ -0,0 +1,52 @@ +class Admin::ApplicationsController < Admin::ApplicationController + before_action :set_application, only: [:show, :edit, :update, :destroy] + + def index + @applications = Doorkeeper::Application.where("owner_id IS NULL") + end + + def show + end + + def new + @application = Doorkeeper::Application.new + end + + def edit + end + + def create + @application = Doorkeeper::Application.new(application_params) + + if @application.save + flash[:notice] = I18n.t(:notice, scope: [:doorkeeper, :flash, :applications, :create]) + redirect_to admin_application_url(@application) + else + render :new + end + end + + def update + if @application.update(application_params) + redirect_to admin_application_path(@application), notice: 'Application was successfully updated.' + else + render :edit + end + end + + def destroy + @application.destroy + redirect_to admin_applications_url, notice: 'Application was successfully destroyed.' + end + + private + + def set_application + @application = Doorkeeper::Application.where("owner_id IS NULL").find(params[:id]) + end + + # Only allow a trusted parameter "white list" through. + def application_params + params[:doorkeeper_application].permit(:name, :redirect_uri) + end +end diff --git a/app/controllers/oauth/applications_controller.rb b/app/controllers/oauth/applications_controller.rb index 3407490e498..efa291d9397 100644 --- a/app/controllers/oauth/applications_controller.rb +++ b/app/controllers/oauth/applications_controller.rb @@ -9,10 +9,8 @@ class Oauth::ApplicationsController < Doorkeeper::ApplicationsController def create @application = Doorkeeper::Application.new(application_params) - if Doorkeeper.configuration.confirm_application_owner? - @application.owner = current_user - end - + @application.owner = current_user + if @application.save flash[:notice] = I18n.t(:notice, scope: [:doorkeeper, :flash, :applications, :create]) redirect_to oauth_application_url(@application) |