Skip to content

Commit

Permalink
[api] ensure correct user is set when doing auto_accept in a loop
Browse files Browse the repository at this point in the history
Ensure that we have a valid user for auto_accept (should not be
possible)

Enforce the right user when running via multiple requests in a loop
  • Loading branch information
adrianschroeter committed Dec 4, 2018
1 parent ae861ca commit fe91d48
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/api/app/models/bs_request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -969,8 +969,12 @@ def auto_accept
return if approver && state == :review

with_lock do
User.current ||= User.find_by_login(creator) if accept_at
User.current = User.find_by_login(approver) if approver
if accept_at
User.current = User.find_by_login(creator)
elsif approver
User.current = User.find_by_login(approver)
end
raise 'Request lacks definition of owner for auto accept' unless User.current

begin
change_state(newstate: 'accepted', comment: 'Auto accept')
Expand Down

0 comments on commit fe91d48

Please sign in to comment.