diff options
author | Rémy Coutable <remy@rymai.me> | 2016-06-01 19:07:23 +0300 |
---|---|---|
committer | Rémy Coutable <remy@rymai.me> | 2016-06-14 14:07:26 +0300 |
commit | d71fbe0dbdb3b7aba6f71e6d3d50daaa890769e9 (patch) | |
tree | 9e0c6fa7768bb5899ddf9e25d009347e462fda9d /app/controllers/groups/group_members_controller.rb | |
parent | d26f81239a33b80694783ee35f0da0e2ed082c9b (diff) |
Factorize #request_access and #approve_access_request into a new AccessRequestActions controller concern
Signed-off-by: Rémy Coutable <remy@rymai.me>
Diffstat (limited to 'app/controllers/groups/group_members_controller.rb')
-rw-r--r-- | app/controllers/groups/group_members_controller.rb | 27 |
1 files changed, 13 insertions, 14 deletions
diff --git a/app/controllers/groups/group_members_controller.rb b/app/controllers/groups/group_members_controller.rb index 2ebc506040f..a37129062f9 100644 --- a/app/controllers/groups/group_members_controller.rb +++ b/app/controllers/groups/group_members_controller.rb @@ -1,4 +1,6 @@ class Groups::GroupMembersController < Groups::ApplicationController + include AccessRequestActions + # Authorize before_action :authorize_admin_group_member!, except: [:index, :leave, :request_access] @@ -82,25 +84,22 @@ class Groups::GroupMembersController < Groups::ApplicationController end end - def request_access - @group.request_access(current_user) + protected - redirect_to group_path(@group), notice: 'Your request for access has been queued for review.' + def member_params + params.require(:group_member).permit(:access_level, :user_id) end - def approve - @group_member = @group.group_members.request.find(params[:id]) - - return render_403 unless can?(current_user, :update_group_member, @group_member) - - @group_member.accept_request - - redirect_to group_group_members_path(@group) + # AccessRequestActions concern + def access_requestable_resource + @group end - protected + def access_requestable_resource_path + group_path(@group) + end - def member_params - params.require(:group_member).permit(:access_level, :user_id) + def access_requestable_resource_members_path + group_group_members_path(@group) end end |