Commit d7728599 authored by Valery Sizov's avatar Valery Sizov

Web hook: controller refactoring

parent 29e8d02a
......@@ -7,4 +7,8 @@ class Groups::ApplicationController < ApplicationController
return render_404
end
end
def group
@group ||= Group.find_by(path: params[:group_id])
end
end
......@@ -71,10 +71,6 @@ class Groups::GroupMembersController < Groups::ApplicationController
protected
def group
@group ||= Group.find_by(path: params[:group_id])
end
def member_params
params.require(:group_member).permit(:access_level, :user_id)
end
......
class Groups::HooksController < ApplicationController
class Groups::HooksController < Groups::ApplicationController
# Authorize
before_filter :group
before_filter :authorize_admin_group!
......@@ -56,14 +56,4 @@ class Groups::HooksController < ApplicationController
def hook_params
params.require(:hook).permit(:url, :push_events, :issues_events, :merge_requests_events, :tag_push_events)
end
def group
@group ||= Group.find_by(path: params[:group_id])
end
def authorize_admin_group!
unless can?(current_user, :manage_group, group)
return render_404
end
end
end
class Groups::LdapGroupLinksController < ApplicationController
class Groups::LdapGroupLinksController < Groups::ApplicationController
before_action :group
before_action :require_ldap_enabled
before_action :authorize_admin_group!
......@@ -28,14 +28,6 @@ class Groups::LdapGroupLinksController < ApplicationController
private
def group
@group ||= Group.find_by(path: params[:group_id])
end
def authorize_admin_group!
render_404 unless can?(current_user, :manage_group, group)
end
def ldap_group_link_params
params.require(:ldap_group_link).permit(:cn, :group_access, :provider)
end
......
class Groups::LdapsController < ApplicationController
class Groups::LdapsController < Groups::ApplicationController
before_filter :group
before_filter :authorize_admin_group!
......@@ -7,16 +7,4 @@ class Groups::LdapsController < ApplicationController
redirect_to members_group_path(@group), notice: 'Access reset complete'
end
private
def group
@group ||= Group.find_by(path: params[:group_id])
end
def authorize_admin_group!
unless can?(current_user, :manage_group, group)
return render_404
end
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment