Skip to Content Skip to Search
Methods
B
C
E
I
M
P
R
U
Included Modules

Instance Public methods

bearer_token()

# File app/controllers/v2/application_controller.rb, line 30
def bearer_token
  pattern = /^Bearer /
  header = request.headers["Authorization"]
  header.gsub(pattern, "") if header&.match(pattern)
end

cors_preflight_check()

# File app/controllers/v2/application_controller.rb, line 24
def cors_preflight_check
  return unless request.method == "OPTIONS"

  head :ok
end

e2e_email?()

# File app/controllers/v2/application_controller.rb, line 50
def e2e_email?
  params[:email]&.match(/^e2etest/) || params[:new_email]&.match(/^e2etest/)
end

info_for_paper_trail()

paper_trail gem-specific magic method keywords: PaperTrail, whodunnit

# File app/controllers/v2/application_controller.rb, line 79
def info_for_paper_trail
  {
    ip:,
    site_id: widget_site_id,
    user_agent: request.user_agent
  }
end

ip()

# File app/controllers/v2/application_controller.rb, line 87
def ip
  request.remote_ip
end

member_ip_address()

# File app/controllers/v2/application_controller.rb, line 67
def member_ip_address
  request.env["HTTP_X_REAL_IP"] || ip
end

paginate(collection)

Helper method for setting pagination headers

# File app/controllers/v2/application_controller.rb, line 13
def paginate(collection)
  headers["X-Page"] = collection.current_page
  headers["X-Per-Page"] = collection.limit_value
  headers["X-Total-Pages"] = collection.total_pages
  headers["X-Total-Count"] = collection.total_count
  headers["X-Next-Page"] = collection.next_page
  headers["X-Previous-Page"] = collection.prev_page
  headers["X-Last-Page"] = collection.last_page?
  headers["X-First-Page"] = collection.first_page?
end

params()

override params implementation

# File app/controllers/v2/application_controller.rb, line 61
def params
  ActionController::Parameters.new(
    request.params.deep_transform_keys!(&:underscore)
  )
end

recaptcha!()

# File app/controllers/v2/application_controller.rb, line 36
def recaptcha!
  return if recaptcha_verifier.verify(params[:captcha], request.ip)

  return_failed_recaptcha
end

recaptcha_verifier()

# File app/controllers/v2/application_controller.rb, line 42
def recaptcha_verifier
  if !!ENV["FAKE_RECAPTCHA_FOR_E2ETEST_EMAILS"] && e2e_email?
    MemberApi::Action::GoogleE2eRecaptcha
  else
    Member::GoogleRecaptcha
  end
end

return_failed_recaptcha()

# File app/controllers/v2/application_controller.rb, line 54
def return_failed_recaptcha
  error = I18n.t("errors.recaptcha_verify_not_robot")

  render_error(error, :forbidden)
end

user_for_paper_trail()

paper_trail gem-specific magic method keywords: PaperTrail, whodunnit

# File app/controllers/v2/application_controller.rb, line 73
def user_for_paper_trail
  current_member_id
end