Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Recaptcha disable flag + null order fix #9505

Merged
merged 2 commits into from
Sep 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions app/controllers/registrations_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,23 @@
prepend_before_action :disable_destroy, only: [:destroy]

def new
respond_to { |format| format.html { redirect_with_authentication('signUp') } }
respond_to { |format| format.html { redirect_with_authentication("signUp") } }
end

private

def check_captcha
return if RootSite.instance.disable_captcha?
return if verify_recaptcha

configure_permitted_parameters # we prepended, so this won't have run
self.resource = resource_class.new sign_up_params
resource.validate # Look for any other validation errors besides Recaptcha
resource.errors.add :recaptcha, 'failed verification'
resource.errors.add :recaptcha, "failed verification"
respond_with resource
end

def disable_destroy
redirect_to root_path, alert: 'To delete your account, please email the site administrators.'
redirect_to root_path, alert: "To delete your account, please email the site administrators."

Check notice on line 26 in app/controllers/registrations_controller.rb

View workflow job for this annotation

GitHub Actions / rubocop

[rubocop] app/controllers/registrations_controller.rb#L26 <Rails/I18nLocaleTexts>

Move locale texts to the locale files in the `config/locales` directory.
Raw output
app/controllers/registrations_controller.rb:26:35: C: Rails/I18nLocaleTexts: Move locale texts to the locale files in the `config/locales` directory.
end
end
1 change: 1 addition & 0 deletions app/models/root_site.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
# Table name: root_sites
#
# id :bigint not null, primary key
# disable_captcha :boolean default(FALSE), not null
# site_name :text
# default_layout_id :bigint
# root_page_id :bigint
Expand Down
3 changes: 2 additions & 1 deletion app/presenters/convention_reports_presenter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,15 @@
"COALESCE(price_per_item_cents, 0)",
"COALESCE(price_per_item_currency, #{ActiveRecord::Base.connection.quote(convention.default_currency_code_or_site_default)})"
)
.where("product_id IS NOT NULL")

Check notice on line 23 in app/presenters/convention_reports_presenter.rb

View workflow job for this annotation

GitHub Actions / rubocop

[rubocop] app/presenters/convention_reports_presenter.rb#L23 <Rails/WhereNot>

Use `where.not(product_id: nil)` instead of manually constructing negated SQL in `where`.
Raw output
app/presenters/convention_reports_presenter.rb:23:14: C: Rails/WhereNot: Use `where.not(product_id: nil)` instead of manually constructing negated SQL in `where`.
.pluck(
:product_id,
:status,
Arel.sql("COALESCE(price_per_item_cents, 0)"),
Arel.sql(
"COALESCE(price_per_item_currency, #{ActiveRecord::Base.connection.quote(convention.default_currency_code_or_site_default)})"
),
Arel.sql("SUM(quantity) sum_quantity")
Arel.sql("COALESCE(SUM(quantity), 0) sum_quantity")
)

grouped_count_data.map do |product_id, status, amount_cents, amount_currency, sum_quantity|
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class AddDisableCaptchaToRootSites < ActiveRecord::Migration[7.2]
def change
add_column :root_sites, :disable_captcha, :boolean, null: false, default: false
end
end
4 changes: 3 additions & 1 deletion db/structure.sql
Original file line number Diff line number Diff line change
Expand Up @@ -2422,7 +2422,8 @@ CREATE TABLE public.root_sites (
id bigint NOT NULL,
site_name text,
root_page_id bigint,
default_layout_id bigint
default_layout_id bigint,
disable_captcha boolean DEFAULT false NOT NULL
);


Expand Down Expand Up @@ -6119,6 +6120,7 @@ ALTER TABLE ONLY public.cms_files_pages
SET search_path TO "$user", public;

INSERT INTO "schema_migrations" (version) VALUES
('20240916155847'),
('20240807155222'),
('20240717150224'),
('20240620014115'),
Expand Down
2 changes: 1 addition & 1 deletion test/factories/root_sites.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
# Table name: root_sites
#
# id :bigint not null, primary key
# disable_captcha :boolean default(FALSE), not null
# site_name :text
# default_layout_id :bigint
# root_page_id :bigint
Expand All @@ -19,7 +20,6 @@
# fk_rails_... (root_page_id => pages.id)
#
# rubocop:enable Layout/LineLength, Lint/RedundantCopDisableDirective
# rubocop:disable Metrics/LineLength, Lint/RedundantCopDisableDirective
FactoryBot.define do
factory :root_site do
site_name { "The Root Site" }
Expand Down
2 changes: 1 addition & 1 deletion test/models/root_site_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
# Table name: root_sites
#
# id :bigint not null, primary key
# disable_captcha :boolean default(FALSE), not null
# site_name :text
# default_layout_id :bigint
# root_page_id :bigint
Expand All @@ -19,7 +20,6 @@
# fk_rails_... (root_page_id => pages.id)
#
# rubocop:enable Layout/LineLength, Lint/RedundantCopDisableDirective
# rubocop:disable Layout/LineLength, Lint/RedundantCopDisableDirective
require "test_helper"

class RootSiteTest < ActiveSupport::TestCase
Expand Down
Loading