Skip to content
This repository was archived by the owner on Jul 24, 2020. It is now read-only.
This repository was archived by the owner on Jul 24, 2020. It is now read-only.

check_tos() causes infinite loop on Checkout #1008

Closed
@dgoerger

Description

@dgoerger

Case:

  • admin does not require users to enter a phone number
  • user account created without a phone number and never accepts ToS
  • admin changes App Settings to require phone number
  • checkoutperson tries to check something out for said user
  • hits code block:
  def check_tos(user)
    return true if user.terms_of_service_accepted

    user.terms_of_service_accepted = params[:terms_of_service_accepted].present?
    return user.terms_of_service_accepted ? user.save : (flash[:error] = "You must confirm that the user accepts the Terms of Service.") && false
  end

If I'm parsing this correctly, the return statement says:

return {
  if user.terms_of_service_accepted
    user.save #invalid without user phone number, will return false
  else
    (flash[:error] = "You must confirm that the user accepts the Terms of Service.") && false #should we be returning strings AND booleans in the same call? is this kosher coding? why don't we set the flash where this is called from?
  end
}

... i.e., there's no way to return true on this function in the above scenario. I'm not sure why the app is spiralling into an infinite loop instead of hitting the redirect_to :back and return and bouncing back to the manage page, but apparently, at least sometimes, it is.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions