diff options
author | Rémy Coutable <remy@rymai.me> | 2017-10-11 17:47:08 +0300 |
---|---|---|
committer | Rémy Coutable <remy@rymai.me> | 2018-02-27 18:02:22 +0300 |
commit | bf41063679b25371b2e64542f2f469b38502edf6 (patch) | |
tree | bc7363df6d75c628f593b29426b59ba05b10a223 /lib | |
parent | 3bf448267b117e79f08ab2f4b769d24a705a5f0f (diff) |
Remove explicit audit event log in MembershipActions
Move it to Members::ApproveAccessRequestService.
Also, note that there was a double audit event log for access request
destruction.
Signed-off-by: Rémy Coutable <remy@rymai.me>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/api/access_requests.rb | 8 | ||||
-rw-r--r-- | lib/api/members.rb | 18 | ||||
-rw-r--r-- | lib/api/v3/members.rb | 2 |
3 files changed, 18 insertions, 10 deletions
diff --git a/lib/api/access_requests.rb b/lib/api/access_requests.rb index 60ae5e6b9a2..23ea05e1105 100644 --- a/lib/api/access_requests.rb +++ b/lib/api/access_requests.rb @@ -53,7 +53,10 @@ module API put ':id/access_requests/:user_id/approve' do source = find_source(source_type, params[:id]) - member = ::Members::ApproveAccessRequestService.new(source, current_user, declared_params).execute + access_requester = source.requesters.find_by!(user_id: params[:user_id]) + member = ::Members::ApproveAccessRequestService + .new(source, current_user, declared_params) + .execute(access_requester) status :created present member, with: Entities::Member @@ -70,8 +73,7 @@ module API member = source.requesters.find_by!(user_id: params[:user_id]) destroy_conditionally!(member) do - ::Members::DestroyService.new(source, current_user, params) - .execute(:requesters) + ::Members::DestroyService.new(source, current_user).execute(member) end end end diff --git a/lib/api/members.rb b/lib/api/members.rb index bc1de37284a..6367cde04bb 100644 --- a/lib/api/members.rb +++ b/lib/api/members.rb @@ -81,12 +81,18 @@ module API source = find_source(source_type, params.delete(:id)) authorize_admin_source!(source_type, source) - member = source.members.find_by!(user_id: params.delete(:user_id)) - - if member.update_attributes(declared_params(include_missing: false)) - present member, with: Entities::Member + member = source.members.find_by!(user_id: params[:user_id]) + updated_member = + ::Members::UpdateService.new( + source, + current_user, + declared_params(include_missing: false) + ).execute(member) + + if updated_member.valid? + present updated_member, with: Entities::Member else - render_validation_error!(member) + render_validation_error!(updated_member) end end @@ -99,7 +105,7 @@ module API member = source.members.find_by!(user_id: params[:user_id]) destroy_conditionally!(member) do - ::Members::DestroyService.new(source, current_user, declared_params).execute + ::Members::DestroyService.new(source, current_user).execute(member) end end end diff --git a/lib/api/v3/members.rb b/lib/api/v3/members.rb index d7bde8ceb89..dddc7d15d42 100644 --- a/lib/api/v3/members.rb +++ b/lib/api/v3/members.rb @@ -124,7 +124,7 @@ module API status(200 ) { message: "Access revoked", id: params[:user_id].to_i } else - ::Members::DestroyService.new(source, current_user, declared_params).execute + ::Members::DestroyService.new(source, current_user).execute(member) present member, with: ::API::Entities::Member end |