Skip to content

Commit

Permalink
rebase to incorporate phone_setup changes. add to error handling from…
Browse files Browse the repository at this point in the history
… FromResponse
  • Loading branch information
kevinsmaster5 committed Apr 30, 2024
1 parent b7d77ce commit 07a7ceb
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion app/controllers/users/phone_setup_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def create
if result.success?
handle_create_success(@new_phone_form.phone)
else
flash.now[:error] = result.first_error_message(:recaptcha_token)
flash.now[:error] = result.first_error_message(:recaptcha_token, :rate_limited)
render :index
end
end
Expand Down
7 changes: 4 additions & 3 deletions app/services/form_response.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,11 @@ def merge(other)
end
end

def first_error_message(key = nil)
def first_error_message(*keys)
return if errors.blank?
key ||= errors.keys.first
errors[key].first
[*keys, errors.keys.first].each do |key|
return errors[key].first if errors.key?(key)
end
end

def ==(other)
Expand Down

0 comments on commit 07a7ceb

Please sign in to comment.