From 3f990c6654ba78cf7a0d33f582e5fb53ec84518b Mon Sep 17 00:00:00 2001 From: Albert Wang Date: Wed, 24 Jul 2019 13:59:43 -0700 Subject: [PATCH 1/9] Fix viewport width. Closes #2052 (#2067) --- public/creators-landing/src/style/style.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/creators-landing/src/style/style.css b/public/creators-landing/src/style/style.css index afe414534d..3f1ed001bb 100644 --- a/public/creators-landing/src/style/style.css +++ b/public/creators-landing/src/style/style.css @@ -78,7 +78,7 @@ h4 { .top-swoop { position: absolute; top: -2px; - width: 100vw !important; + width: 100% !important; } .bottom-swoop { From b50ed5cf4b5246ba798f5d55f5f85fd76f680814 Mon Sep 17 00:00:00 2001 From: Albert Wang Date: Wed, 24 Jul 2019 14:37:16 -0700 Subject: [PATCH 2/9] * Fix sorting on unattached promos (#2069) * Add pagination Closes #1597 --- .../pages/unattached_promo_registrations.scss | 8 ++++++-- .../unattached_promo_registrations_controller.rb | 16 +++++++++++----- .../index.html.slim | 6 ++++-- 3 files changed, 21 insertions(+), 9 deletions(-) diff --git a/app/assets/stylesheets/admin/pages/unattached_promo_registrations.scss b/app/assets/stylesheets/admin/pages/unattached_promo_registrations.scss index a9660df971..616ae6051e 100644 --- a/app/assets/stylesheets/admin/pages/unattached_promo_registrations.scss +++ b/app/assets/stylesheets/admin/pages/unattached_promo_registrations.scss @@ -10,7 +10,7 @@ } .panel { - background: aliceblue; + background: Lavender; flex: 1; border-width: 1px; border-radius: 15px; @@ -21,6 +21,10 @@ background: white; } + &--gray{ + background: whitesmoke; + } + .panel--header { font-size: 20px; font-weight: bold; @@ -145,4 +149,4 @@ } } } -} \ No newline at end of file +} diff --git a/app/controllers/admin/unattached_promo_registrations_controller.rb b/app/controllers/admin/unattached_promo_registrations_controller.rb index 6d9291e3b6..3fe0f9c4b2 100644 --- a/app/controllers/admin/unattached_promo_registrations_controller.rb +++ b/app/controllers/admin/unattached_promo_registrations_controller.rb @@ -5,17 +5,23 @@ def index filter = params[:filter] case filter when "All codes", nil, "" - @promo_registrations = PromoRegistration.unattached_only.order("created_at DESC") + @promo_registrations = PromoRegistration.unattached_only. + paginate(page: params[:page]). + order("created_at DESC") when "Not assigned" - @promo_registrations = PromoRegistration.unattached_only.where(promo_campaign_id: nil).order("created_at DESC") + @promo_registrations = PromoRegistration.unattached_only. + where(promo_campaign_id: nil). + paginate(page: params[:page]). + order("created_at DESC") else @promo_registrations = PromoRegistration.joins(:promo_campaign). unattached_only. where(promo_campaigns: {name: filter}). + paginate(page: params[:page]). order("created_at DESC") end @current_campaign = params[:filter] || "All codes" - @campaigns = PromoCampaign.all.map {|campaign| campaign.name} + @campaigns = PromoCampaign.pluck(:name).sort end def create @@ -37,7 +43,7 @@ def report return redirect_to admin_unattached_promo_registrations_path(filter: params[:filter]), alert: "Please check at least one of downloads, installs, or confirmations." end - + report_start_and_end_date = parse_report_dates(params[:referral_code_report_period], @reporting_interval) report_csv = Promo::RegistrationStatsReportGenerator.new(referral_codes: referral_codes, start_date: report_start_and_end_date[:start_date], @@ -96,4 +102,4 @@ def parse_report_dates(report_period, reporting_interval) def create_params params.require(:number_of_codes_to_create) end -end \ No newline at end of file +end diff --git a/app/views/admin/unattached_promo_registrations/index.html.slim b/app/views/admin/unattached_promo_registrations/index.html.slim index b1b2d3b752..cf3e1ca46c 100644 --- a/app/views/admin/unattached_promo_registrations/index.html.slim +++ b/app/views/admin/unattached_promo_registrations/index.html.slim @@ -18,7 +18,7 @@ = text_field_tag "campaign_name", nil, placeholder: "Campaign name" = submit_tag "Create", class: "btn btn-info", style: "float: right" .row - .panel.panel--white.panel--table + .panel.panel--gray.panel--table .panel--header = "Manage" . style="color: darkgrey; font-size: 14px; margin-bottom: 5px;" - if Rails.cache.fetch('unattached_promo_registration_stats_last_synced_at').nil? @@ -31,7 +31,7 @@ = form_tag admin_unattached_promo_registrations_path, method: :patch, id: "unattached-referral-code-form" do table.table tr - th + th th = "Code" th = "Campaign" th = "Installer Type" @@ -70,6 +70,8 @@ td = promo_registration_aggregate_stats[PromoRegistration::RETRIEVALS] || 0 td = promo_registration_aggregate_stats[PromoRegistration::FIRST_RUNS] || 0 td = promo_registration_aggregate_stats[PromoRegistration::FINALIZED] || 0 + = will_paginate @promo_registrations + hr .flex .unattached-referral-code-form--submissions .panel From 7637850eeb48dc4d8e6200815fcdca82b8f6bcf8 Mon Sep 17 00:00:00 2001 From: Albert Wang Date: Wed, 24 Jul 2019 17:01:52 -0700 Subject: [PATCH 3/9] Change exclusion list to contain uphold (#2071) --- config/excluded_site_channels.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/config/excluded_site_channels.yml b/config/excluded_site_channels.yml index e79ad43694..dfc5462bd5 100644 --- a/config/excluded_site_channels.yml +++ b/config/excluded_site_channels.yml @@ -13389,6 +13389,7 @@ - "updateworkfreshandnew.space" # commerce - "upfifacoins.com" # commerce - "uphe.com" # commerce +- "uphold.com" # services - "uplay.it" # services - "uplds.com" # services - "uploads.to" # services From ae044d7b46ad14880e531fc22bf022a104b306c1 Mon Sep 17 00:00:00 2001 From: Cory McDonald Date: Mon, 29 Jul 2019 12:46:17 -0400 Subject: [PATCH 4/9] Only show public notes (#2078) --- app/controllers/publishers/cases_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/publishers/cases_controller.rb b/app/controllers/publishers/cases_controller.rb index 0bcfbc59e7..8026eedc4b 100644 --- a/app/controllers/publishers/cases_controller.rb +++ b/app/controllers/publishers/cases_controller.rb @@ -10,7 +10,7 @@ def new def show @case = Case.find_by(publisher: current_publisher) - @notes = CaseNote.where(case: @case) + @notes = CaseNote.where(case: @case, public: true) redirect_to new_case_path if @case.blank? || @case.new? end From b56ee5455d37457cf0776aa6ac4e45cb8b327c73 Mon Sep 17 00:00:00 2001 From: Albert Wang Date: Mon, 29 Jul 2019 11:46:53 -0700 Subject: [PATCH 5/9] Check to see if entry exists during lookup on a PromoRegistration. Closes #2073 (#2076) --- app/services/promo/registrations_stats_fetcher.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/services/promo/registrations_stats_fetcher.rb b/app/services/promo/registrations_stats_fetcher.rb index 0f7650f28e..df365fa87c 100644 --- a/app/services/promo/registrations_stats_fetcher.rb +++ b/app/services/promo/registrations_stats_fetcher.rb @@ -22,7 +22,7 @@ def perform referral_code_events_by_date = JSON.parse(response.body) referral_code_batch.each do |referral_code| promo_registration = PromoRegistration.find_by_referral_code(referral_code) - next if referral_code.nil? + next if promo_registration.nil? promo_registration.stats = referral_code_events_by_date.select { |referral_code_event_date| referral_code_event_date["referral_code"] == referral_code }.to_json From a2a6e21dea1ca2ae4adc70565fe96da1e3f669e7 Mon Sep 17 00:00:00 2001 From: Albert Wang Date: Mon, 29 Jul 2019 16:58:09 -0700 Subject: [PATCH 6/9] Fix sync config for zendesk and enable sync (#2075) --- app/jobs/sync/zendesk/ticket_comments_to_notes.rb | 5 +++-- app/jobs/sync/zendesk/tickets_to_notes.rb | 6 +++--- config/sidekiq.yml | 4 ++++ 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/app/jobs/sync/zendesk/ticket_comments_to_notes.rb b/app/jobs/sync/zendesk/ticket_comments_to_notes.rb index b5dc2ce227..069bd30715 100644 --- a/app/jobs/sync/zendesk/ticket_comments_to_notes.rb +++ b/app/jobs/sync/zendesk/ticket_comments_to_notes.rb @@ -10,14 +10,15 @@ def perform(zendesk_ticket_id, page_number = 0) config.url = "#{Rails.application.secrets[:zendesk_url]}/api/v2" # e.g. https://mydesk.zendesk.com/api/v2 # Basic / Token Authentication - config.username = Rails.application.secrets[:zendesk_username] + config.username = "#{Rails.application.secrets[:zendesk_username]}/token" # Choose one of the following depending on your authentication choice # config.token = "your zendesk token" + config.token = Rails.application.secrets[:zendesk_access_token] # config.password = "your zendesk password" # OAuth Authentication - config.access_token = Rails.application.secrets[:zendesk_access_token] + # config.access_token = "" # Optional: diff --git a/app/jobs/sync/zendesk/tickets_to_notes.rb b/app/jobs/sync/zendesk/tickets_to_notes.rb index 41f4256464..c381118c56 100644 --- a/app/jobs/sync/zendesk/tickets_to_notes.rb +++ b/app/jobs/sync/zendesk/tickets_to_notes.rb @@ -9,14 +9,14 @@ def perform(page_number = 0, start_date = nil) config.url = "#{Rails.application.secrets[:zendesk_url]}/api/v2" # e.g. https://mydesk.zendesk.com/api/v2 # Basic / Token Authentication - config.username = Rails.application.secrets[:zendesk_username] + config.username = "#{Rails.application.secrets[:zendesk_username]}/token" # Choose one of the following depending on your authentication choice - # config.token = "your zendesk token" + config.token = Rails.application.secrets[:zendesk_access_token] # config.password = "your zendesk password" # OAuth Authentication - config.access_token = Rails.application.secrets[:zendesk_access_token] + # config.access_token = "" # Optional: diff --git a/config/sidekiq.yml b/config/sidekiq.yml index bebd62d2c6..c84e910b3e 100644 --- a/config/sidekiq.yml +++ b/config/sidekiq.yml @@ -36,6 +36,10 @@ cron: "0 1 * * *" description: "Syncs the channel stats via youtube and twitch apis" queue: low + Sync::Zendesk::StartJob: + cron: "0 1 * * *" + description: "Syncs zendesk tickets" + queue: low Cache::PiwikDataJob: cron: "45 2 * * *" description: "Refreshes the redis cache for piwik information everyday at 2:45 AM" From fef1890ed5fc0df456c1cae909fdd4542f3d3037 Mon Sep 17 00:00:00 2001 From: Albert Wang Date: Tue, 30 Jul 2019 09:48:33 -0700 Subject: [PATCH 7/9] Fixes cases if the user isn't signed in. Closes #2072 (#2077) * Fixes cases if the user isn't signed in. Closes #2072 * Remove PublisherPromoTokenGenerator * Use redirect rather than trying to render for a POST request * Remove unused test. --- .../promo_registrations_controller.rb | 39 +++---------- .../publisher_promo_token_generator.rb | 36 ------------ .../promo_registrations/create.html.slim | 2 +- lib/tasks/launch_promo.rake | 25 --------- .../promo_registrations_controller_test.rb | 34 +----------- .../publisher_promo_token_generator_test.rb | 51 ----------------- test/tasks/launch_promo_test.rb | 55 ------------------- 7 files changed, 11 insertions(+), 231 deletions(-) delete mode 100644 app/services/publisher_promo_token_generator.rb delete mode 100644 lib/tasks/launch_promo.rake delete mode 100644 test/services/publisher_promo_token_generator_test.rb delete mode 100644 test/tasks/launch_promo_test.rb diff --git a/app/controllers/promo_registrations_controller.rb b/app/controllers/promo_registrations_controller.rb index 0dedf59023..834699bb49 100644 --- a/app/controllers/promo_registrations_controller.rb +++ b/app/controllers/promo_registrations_controller.rb @@ -1,14 +1,17 @@ class PromoRegistrationsController < ApplicationController include PromosHelper - - before_action :find_publisher + before_action :authenticate_publisher! before_action :require_publisher_promo_disabled, only: %(create) before_action :require_promo_running, only: %i(create) def index + @publisher = current_publisher + @publisher_promo_status = @publisher.promo_status(promo_running?) + @promo_enabled_channels = @publisher.channels.joins(:promo_registration) end def create + @publisher = current_publisher @publisher.promo_enabled_2018q1 = true @publisher.save! @publisher_has_verified_channel = @publisher.has_verified_channel? @@ -31,39 +34,13 @@ def create def require_promo_running unless promo_running? - render(:index) + redirect_to promo_registrations_path, action: "index" end end def require_publisher_promo_disabled - if @publisher.promo_enabled_2018q1 - render(:index) - end - end - - def find_publisher - if current_publisher - @publisher = current_publisher - else - if params[:promo_token].present? - promo_token = params[:promo_token] - elsif params.dig(:publisher).dig(:promo_token).present? - promo_token = params[:publisher][:promo_token] - else - return redirect_to(root_path, alert: I18n.t("promo.publisher_not_found")) - end - if publisher = Publisher.find_by(promo_token_2018q1: promo_token) - @publisher = publisher - else - return redirect_to(root_path, alert: I18n.t("promo.publisher_not_found")) - end + if current_publisher.promo_enabled_2018q1 + redirect_to promo_registrations_path, action: "index" end - - @publisher_promo_status = @publisher.promo_status(promo_running?) - @promo_enabled_channels = @publisher.channels.joins(:promo_registration) - rescue => e - require "sentry-raven" - Raven.capture_exception(e) - return redirect_to(root_path, alert: I18n.t("promo.publisher_not_found")) end end diff --git a/app/services/publisher_promo_token_generator.rb b/app/services/publisher_promo_token_generator.rb deleted file mode 100644 index bb5135cd6a..0000000000 --- a/app/services/publisher_promo_token_generator.rb +++ /dev/null @@ -1,36 +0,0 @@ -# Generates a token for a publisher for 2018q1 promotion -class PublisherPromoTokenGenerator < BaseService - include PromosHelper - - attr_reader :publisher - - def initialize(publisher:, promo_id: active_promo_id, force: false) - @publisher = publisher - @promo_id = promo_id - @force = force - end - - def perform - require "sentry-raven" - case @promo_id - when "free-bats-2018q1" - return perform_2018q1 - else - raise InvalidPromoIdError.new("#{@promo_id} is an invalid promo id") # Rescued and reported in launch promo rake task - end - end - - def perform_2018q1 - already_has_promo_token = publisher.promo_token_2018q1.present? - - if already_has_promo_token && !@force - Rails.logger.info("Publisher #{@publisher.owner_identifier} already has a promo token, use force=true to overwrite.") - nil - else - publisher.promo_token_2018q1 = SecureRandom.hex(32) - publisher.save! - publisher.promo_token_2018q1 - end - end - class InvalidPromoIdError < RuntimeError; end -end \ No newline at end of file diff --git a/app/views/promo_registrations/create.html.slim b/app/views/promo_registrations/create.html.slim index 94ef8f7937..1ae0e726c3 100644 --- a/app/views/promo_registrations/create.html.slim +++ b/app/views/promo_registrations/create.html.slim @@ -1,4 +1,4 @@ - if @publisher_has_verified_channel = render "activated_verified", locals: @publisher - else - = render "activated_unverified", locals: @publisher \ No newline at end of file + = render "activated_unverified", locals: @publisher diff --git a/lib/tasks/launch_promo.rake b/lib/tasks/launch_promo.rake deleted file mode 100644 index 5984d0804f..0000000000 --- a/lib/tasks/launch_promo.rake +++ /dev/null @@ -1,25 +0,0 @@ -require "#{Rails.root}/app/helpers/promos_helper" -namespace :promo do - # Generates the promo tokens and sends emails - task :launch_promo => :environment do - include PromosHelper - begin - unless promo_running? - puts "Promo is not running, check the active_promo_id config var." - end - - publishers = Publisher.where(promo_token_2018q1: nil).where(promo_enabled_2018q1: false).where.not(email: nil) - - publishers.find_each do |publisher| - token = PublisherPromoTokenGenerator.new(publisher: publisher).perform - next unless token - PromoMailer.activate_promo_2018q1(publisher).deliver_later(queue: :low) - end - - rescue PublisherPromoTokenGenerator::InvalidPromoIdError => error - require "raven" - Raven.capture_exception(error) - puts "Did not launch promo because of invalid promo id. Check the active_promo_id config var." - end - end -end \ No newline at end of file diff --git a/test/controllers/promo_registrations_controller_test.rb b/test/controllers/promo_registrations_controller_test.rb index f555f6d012..c05bcb03b4 100644 --- a/test/controllers/promo_registrations_controller_test.rb +++ b/test/controllers/promo_registrations_controller_test.rb @@ -37,6 +37,7 @@ class PromoRegistrationsControllerTest < ActionDispatch::IntegrationTest # verify _over is rendered post promo_registrations_path + follow_redirect! assert_select("[data-test=promo-over]") # verify publisher has not enabled promo @@ -52,6 +53,7 @@ class PromoRegistrationsControllerTest < ActionDispatch::IntegrationTest # verify _over is rendered post promo_registrations_path + follow_redirect! assert_select("[data-test=promo-active]") # verify publisher has not enabled promo @@ -131,38 +133,6 @@ class PromoRegistrationsControllerTest < ActionDispatch::IntegrationTest assert_select("[data-test=promo-active]") end - test "publisher can activate/visit promo without being signed in using promo token from email" do - publisher = publishers(:completed) - - # ensure we use token, not session for promo auth - sign_out publisher - - promo_token = PublisherPromoTokenGenerator.new(publisher: publisher).perform - - # verify promo token auth takes you to _activate page - url = promo_registrations_path(promo_token: promo_token) - get url - assert_response 200 - assert_select("[data-test=promo-activate]") - - # verify the above does not enable the promo - assert_equal publisher.promo_enabled_2018q1, false - - # verify promo auth allows promo activation, takes publisher to _activated_verified - post url - publisher.reload - assert_equal publisher.promo_enabled_2018q1, true - assert_select("[data-test=promo-activated-verified]") - - # verify promo auth allows users to view active page once authorized - get url - assert_select("[data-test=promo-active]") - - # verify publisher is not must reauth to visit dashboard - get home_publishers_path(publisher) - assert_response 401 # Unauthorized # TO DO: See screen this takes you to, ideally dashboard - end - test "all requests with no promo_token in params or publisher in the session redirect homepage" do publisher = publishers(:completed) sign_out publisher diff --git a/test/services/publisher_promo_token_generator_test.rb b/test/services/publisher_promo_token_generator_test.rb deleted file mode 100644 index e72247e1b0..0000000000 --- a/test/services/publisher_promo_token_generator_test.rb +++ /dev/null @@ -1,51 +0,0 @@ -require "test_helper" -require "webmock/minitest" - -class PublisherPromoTokenGeneratorTest < ActiveJob::TestCase - include PromosHelper - - test "generator generates 2018q1 token" do - publisher = publishers(:completed) - PublisherPromoTokenGenerator.any_instance.stubs(:active_promo_id).returns("free-bats-2018q1") - PublisherPromoTokenGenerator.new(publisher: publisher).perform - - assert_not_nil publisher.promo_token_2018q1 - end - - test "generator doesn't overwrite existing 2018q1 token" do - publisher = publishers(:completed) - PublisherPromoTokenGenerator.any_instance.stubs(:active_promo_id).returns("free-bats-2018q1") - generator = PublisherPromoTokenGenerator.new(publisher: publisher) - - # generate token - generator.perform - promo_token = publisher.promo_token_2018q1 - - # verify generator doesn't overwrite existing token - generator.perform - assert_equal promo_token, publisher.promo_token_2018q1 - end - - test "generator will overwrite existing 2018q1 token with param force=true" do - publisher = publishers(:completed) - PublisherPromoTokenGenerator.any_instance.stubs(:active_promo_id).returns("free-bats-2018q1") - PublisherPromoTokenGenerator.new(publisher: publisher).perform - - first_promo_token = publisher.promo_token_2018q1 - PublisherPromoTokenGenerator.new(publisher: publisher, force: true).perform - second_promo_token = publisher.promo_token_2018q1 - - assert_not_equal first_promo_token, second_promo_token - end - - test "generator raises error if promo_id is invalid, no 2018q1 tokens are generated" do - publisher = publishers(:completed) - - # use invalid active_promo_id - PublisherPromoTokenGenerator.any_instance.stubs(:active_promo_id).returns("invalid-promo-id") - - assert_raise PublisherPromoTokenGenerator::InvalidPromoIdError do - PublisherPromoTokenGenerator.new(publisher: publisher).perform - end - end -end \ No newline at end of file diff --git a/test/tasks/launch_promo_test.rb b/test/tasks/launch_promo_test.rb deleted file mode 100644 index 8aaa314271..0000000000 --- a/test/tasks/launch_promo_test.rb +++ /dev/null @@ -1,55 +0,0 @@ -require 'test_helper' - -class LaunchPromoTest < ActiveJob::TestCase - - before do - require 'rake' - Rake::Task.define_task :environment - Rails.application.load_tasks - end - - test "generates a promo token and sends email to each publisher" do - assert_difference("Publisher.where.not(promo_token_2018q1: nil).count", Publisher.where.not(email: nil, promo_enabled_2018q1: true).count) do - assert_enqueued_jobs(Publisher.where.not(email: nil, promo_enabled_2018q1: true).count) do - Rake::Task["promo:launch_promo"].invoke - Rake::Task["promo:launch_promo"].reenable - end - end - end - - test "only sends one email to each publisher if run twice (idempotence)" do - publisher_one = publishers(:completed).dup - publisher_two = publishers(:verified).dup - - PublisherNote.destroy_all - Publisher.delete_all - - publisher_one.save! - assert_equal Publisher.count, 1 # sanity check - - # run task once and store publisher_one's promo token - assert_difference("Publisher.where.not(promo_token_2018q1: nil).count", 1) do - assert_enqueued_jobs(1) do - Rake::Task["promo:launch_promo"].invoke - Rake::Task["promo:launch_promo"].reenable - end - end - publisher_one.reload - promo_token_one = publisher_one.promo_token_2018q1 - - # add a second publisher - publisher_two.save! - assert_equal Publisher.count, 2 - - # run task again and verify it has no effect on publisher_one - assert_difference("Publisher.where.not(promo_token_2018q1: nil).count", 1) do - assert_enqueued_jobs(1) do - Rake::Task["promo:launch_promo"].invoke - Rake::Task["promo:launch_promo"].reenable - end - end - - # verify promo_token_one matches after rake task run twice - assert_equal promo_token_one, publisher_one.promo_token_2018q1 - end -end From 432fa6ed52a537f04f9b65e37d2b64e96208b777 Mon Sep 17 00:00:00 2001 From: Albert Wang Date: Tue, 30 Jul 2019 10:27:27 -0700 Subject: [PATCH 8/9] Feature: Delete account (#2058) * Feature: Self-service account removal * Move Delete Account to Settings menu --- app/assets/stylesheets/theme/columns.scss | 2 +- app/assets/stylesheets/theme/panels.scss | 10 +- .../concerns/two_factor_registration.rb | 2 +- .../publishers/security_controller.rb | 18 +++ .../publishers/settings_controller.rb | 8 ++ app/controllers/publishers_controller.rb | 8 +- .../totp_registrations_controller.rb | 2 +- .../two_factor_registrations_controller.rb | 16 --- .../u2f_registrations_controller.rb | 2 +- app/javascript/components/navbar/Navbar.tsx | 5 + app/javascript/locale/en.ts | 3 +- app/javascript/routes/routes.ts | 3 + app/views/application/_nav.html.slim | 3 +- .../security}/index.html.slim | 15 ++- .../security}/prompt.html.slim | 2 +- app/views/publishers/settings/index.html.slim | 20 +++ app/views/totp_registrations/new.html.slim | 2 +- app/views/u2f_registrations/new.html.slim | 2 +- config/application.rb | 4 + config/environments/development.rb | 2 + config/i18n-tasks.yml | 36 +++-- config/initializers/locale.rb | 3 + config/locales/en.yml | 124 +----------------- .../locales/views/publishers/security/en.yml | 75 +++++++++++ .../locales/views/publishers/settings/en.yml | 15 +++ config/locales/views/u2f_registrations/en.yml | 50 +++++++ config/routes.rb | 10 +- .../controllers/publishers_controller_test.rb | 2 +- .../totp_registrations_controller_test.rb | 6 +- ...wo_factor_registrations_controller_test.rb | 10 +- .../u2f_registrations_controller_test.rb | 6 +- test/features/sign_up_test.rb | 2 +- .../features/two_factor_registrations_test.rb | 4 +- yarn.lock | 17 +-- 34 files changed, 288 insertions(+), 201 deletions(-) create mode 100644 app/controllers/publishers/security_controller.rb create mode 100644 app/controllers/publishers/settings_controller.rb delete mode 100644 app/controllers/two_factor_registrations_controller.rb rename app/views/{two_factor_registrations => publishers/security}/index.html.slim (91%) rename app/views/{two_factor_registrations => publishers/security}/prompt.html.slim (81%) create mode 100644 app/views/publishers/settings/index.html.slim create mode 100644 config/initializers/locale.rb create mode 100644 config/locales/views/publishers/security/en.yml create mode 100644 config/locales/views/publishers/settings/en.yml create mode 100644 config/locales/views/u2f_registrations/en.yml diff --git a/app/assets/stylesheets/theme/columns.scss b/app/assets/stylesheets/theme/columns.scss index 3418d99f5d..01816a93ff 100644 --- a/app/assets/stylesheets/theme/columns.scss +++ b/app/assets/stylesheets/theme/columns.scss @@ -62,7 +62,7 @@ } } -.col-two-factor { +.col-left-aligned { &--content { @include make-col-ready(); text-align: left; diff --git a/app/assets/stylesheets/theme/panels.scss b/app/assets/stylesheets/theme/panels.scss index 4df5e7f2b4..dbbd4a36d5 100644 --- a/app/assets/stylesheets/theme/panels.scss +++ b/app/assets/stylesheets/theme/panels.scss @@ -9,7 +9,7 @@ $brave-panels-borderRadius: 8px; max-width: $spacer * 40; min-height: $spacer * 32; margin: 0 auto; - padding: 0 15px; + padding: 0 10px; display: flex; flex-direction: column; @@ -21,6 +21,10 @@ $brave-panels-borderRadius: 8px; min-height: $spacer * 10; } + &--short { + min-height: $spacer * 8; + } + &--medium { max-width: $spacer * 45; } @@ -134,6 +138,10 @@ $brave-panels-borderRadius: 8px; margin-top: auto; margin-bottom: auto; + &--short-padding { + padding: $spacer * 3 $spacer * 2; + } + &--email-sent { padding-top: 125px; margin-top: 30px; diff --git a/app/controllers/concerns/two_factor_registration.rb b/app/controllers/concerns/two_factor_registration.rb index 1eeab12e97..fc5f139294 100644 --- a/app/controllers/concerns/two_factor_registration.rb +++ b/app/controllers/concerns/two_factor_registration.rb @@ -15,7 +15,7 @@ def handle_redirect_after_2fa_registration end end - redirect_to two_factor_registrations_path + redirect_to security_publishers_path end def flag_2fa_registration_during_signup diff --git a/app/controllers/publishers/security_controller.rb b/app/controllers/publishers/security_controller.rb new file mode 100644 index 0000000000..5aae84d4b1 --- /dev/null +++ b/app/controllers/publishers/security_controller.rb @@ -0,0 +1,18 @@ +require "concerns/two_factor_registration" + +module Publishers + class SecurityController < ApplicationController + include PublishersHelper + include TwoFactorRegistration + + before_action :authenticate_publisher! + + def index + @u2f_registrations = current_publisher.u2f_registrations + end + + def prompt + flag_2fa_registration_during_signup + end + end +end diff --git a/app/controllers/publishers/settings_controller.rb b/app/controllers/publishers/settings_controller.rb new file mode 100644 index 0000000000..b0745f4912 --- /dev/null +++ b/app/controllers/publishers/settings_controller.rb @@ -0,0 +1,8 @@ +module Publishers + class SettingsController < ApplicationController + before_action :authenticate_publisher! + + def index + end + end +end diff --git a/app/controllers/publishers_controller.rb b/app/controllers/publishers_controller.rb index 01ddc125e3..4a4e98ccb7 100644 --- a/app/controllers/publishers_controller.rb +++ b/app/controllers/publishers_controller.rb @@ -270,6 +270,12 @@ def show redirect_to(publisher_next_step_path(current_publisher)) end + def destroy + PublisherRemovalJob.perform_later(publisher_id: current_publisher.id) + sign_out(current_publisher) + redirect_to(root_path) + end + def redirect_if_suspended # Redirect to suspended page if they're logged in redirect_to(suspended_error_publishers_path) and return if current_publisher.present? && current_publisher.suspended? @@ -442,7 +448,7 @@ def require_publisher_email_verified_through_youtube_auth def prompt_for_two_factor_setup return if current_publisher.two_factor_prompted_at.present? || two_factor_enabled?(current_publisher) current_publisher.update! two_factor_prompted_at: Time.now - redirect_to prompt_two_factor_registrations_path + redirect_to prompt_security_publishers_path end def update_sendgrid(publisher:, prior_email: nil) diff --git a/app/controllers/totp_registrations_controller.rb b/app/controllers/totp_registrations_controller.rb index 79a7cd01c2..2f70a8f77c 100644 --- a/app/controllers/totp_registrations_controller.rb +++ b/app/controllers/totp_registrations_controller.rb @@ -29,7 +29,7 @@ def create def destroy current_publisher.totp_registration.destroy! if current_publisher.totp_registration.present? - redirect_to two_factor_registrations_path + redirect_to security_publishers_path end private diff --git a/app/controllers/two_factor_registrations_controller.rb b/app/controllers/two_factor_registrations_controller.rb deleted file mode 100644 index 8dee9fc961..0000000000 --- a/app/controllers/two_factor_registrations_controller.rb +++ /dev/null @@ -1,16 +0,0 @@ -require "concerns/two_factor_registration" - -class TwoFactorRegistrationsController < ApplicationController - include PublishersHelper - include TwoFactorRegistration - - before_action :authenticate_publisher! - - def index - @u2f_registrations = current_publisher.u2f_registrations - end - - def prompt - flag_2fa_registration_during_signup - end -end diff --git a/app/controllers/u2f_registrations_controller.rb b/app/controllers/u2f_registrations_controller.rb index 77064d819c..19bcf0ff4b 100644 --- a/app/controllers/u2f_registrations_controller.rb +++ b/app/controllers/u2f_registrations_controller.rb @@ -48,7 +48,7 @@ def destroy u2f_registration = current_publisher.u2f_registrations.find(params[:id]) u2f_registration.destroy - redirect_to two_factor_registrations_path + redirect_to security_publishers_path end end diff --git a/app/javascript/components/navbar/Navbar.tsx b/app/javascript/components/navbar/Navbar.tsx index d676ffd60c..26f6560cea 100644 --- a/app/javascript/components/navbar/Navbar.tsx +++ b/app/javascript/components/navbar/Navbar.tsx @@ -131,6 +131,11 @@ function Dropdown(props) { > {locale.navbar.security} + (window.location.href = routes.navbar.settings.path)} + > + {locale.navbar.settings} + (window.location.href = routes.navbar.help.path)} > diff --git a/app/javascript/locale/en.ts b/app/javascript/locale/en.ts index 0097b663b5..f3d74f147c 100644 --- a/app/javascript/locale/en.ts +++ b/app/javascript/locale/en.ts @@ -32,7 +32,8 @@ export default { logOut: "Log Out", payments: "Payments", referrals: "Referrals", - security: "Security" + security: "Security", + settings: "Settings" }, notEnoughTokens: "Not enough tokens", off: " ", diff --git a/app/javascript/routes/routes.ts b/app/javascript/routes/routes.ts index 3dec08feb1..77ee260a21 100644 --- a/app/javascript/routes/routes.ts +++ b/app/javascript/routes/routes.ts @@ -37,6 +37,9 @@ export default { }, security: { path: "/publishers/two_factor_registrations" + }, + settings: { + path: "/publishers/settings" } } }; diff --git a/app/views/application/_nav.html.slim b/app/views/application/_nav.html.slim index ac8812b248..09b07a811c 100644 --- a/app/views/application/_nav.html.slim +++ b/app/views/application/_nav.html.slim @@ -21,12 +21,13 @@ nav.navbar.navbar-default.navbar-static-top.top-nav-collapse .user-name.js-user-name-dropdown= current_publisher.name .user-email= current_publisher.email ul.user-links - li= link_to two_factor_registrations_path do + li= link_to security_publishers_path do span.user-links-lock .user-links-lock-icon= render two_factor_enabled?(current_publisher) ? "locked_svg" : "unlocked_svg" = t ".security" - if show_faq_link? li= link_to t(".faqs"), faqs_path + li= link_to t(".settings"), settings_publishers_path li= link_to t(".help"), "https://support.brave.com/hc/en-us/" li= link_to t(".log_out"), log_out_publishers_path - else diff --git a/app/views/two_factor_registrations/index.html.slim b/app/views/publishers/security/index.html.slim similarity index 91% rename from app/views/two_factor_registrations/index.html.slim rename to app/views/publishers/security/index.html.slim index 8363bde354..40518b8740 100644 --- a/app/views/two_factor_registrations/index.html.slim +++ b/app/views/publishers/security/index.html.slim @@ -2,17 +2,17 @@ .single-panel--content .single-panel--padded-content .row - .col-two-factor--content + .col-left-aligned--content h3.single-panel--headline= t ".heading" p= t ".intro" - .col-two-factor--action.two-factor-enabled-status + .col-left-aligned--action.two-factor-enabled-status - if two_factor_enabled?(current_publisher) span.two-factor-enabled= t ".enabled_yes" - else span.two-factor-disabled= t ".enabled_no" br - .col-two-factor--content + .col-left-aligned--content h5= t ".totp.heading" p= t ".totp.intro" - if totp_enabled?(current_publisher) @@ -32,7 +32,7 @@ p.two-factor-method-disabled == "• " = t ".totp.disabled" - .col-two-factor--action + .col-left-aligned--action - if totp_enabled?(current_publisher) p= link_to \ t(".totp.destroy"), @@ -68,7 +68,7 @@ p= link_to t(".totp.button"), new_totp_registration_path, class: "btn btn-block btn-primary", :"data-piwik-action" => "CreateTOTPClicked", :"data-piwik-name" => "Clicked", :"data-piwik-value" => "2FA" p.icon= render "smartphone_with_code" - .col-two-factor--content + .col-left-aligned--content h5= t ".u2f.heading" p = t ".u2f.intro" @@ -89,11 +89,12 @@ span.tf-tooltip-content-heading= t ".u2f.device.heading" span.tf-tooltip-content-content== t ".u2f.device.content_html" - if @u2f_registrations.any? - p= render @u2f_registrations + - @u2f_registrations.each do |u2f_registration| + = render partial: "u2f_registrations/u2f_registration", locals: { u2f_registration: u2f_registration } - else p.two-factor-method-disabled == "• " = t ".u2f.disabled" - .col-two-factor--action + .col-left-aligned--action p= link_to t(".u2f.button"), new_u2f_registration_path, class: "btn btn-block btn-primary", :"data-piwik-action" => "CreateU2FClicked", :"data-piwik-name" => "Clicked", :"data-piwik-value" => "2FA" p.icon= render "usb" diff --git a/app/views/two_factor_registrations/prompt.html.slim b/app/views/publishers/security/prompt.html.slim similarity index 81% rename from app/views/two_factor_registrations/prompt.html.slim rename to app/views/publishers/security/prompt.html.slim index 4fe0e126a0..a59c7cdeff 100644 --- a/app/views/two_factor_registrations/prompt.html.slim +++ b/app/views/publishers/security/prompt.html.slim @@ -15,4 +15,4 @@ .col-buttons-half = link_to t(".skip"), home_publishers_path, class: "btn btn-link-primary btn-block" .col-buttons-half - = link_to t(".setup"), two_factor_registrations_path, class: "btn btn-primary btn-block" + = link_to t(".setup"), security_publishers_path, class: "btn btn-primary btn-block" diff --git a/app/views/publishers/settings/index.html.slim b/app/views/publishers/settings/index.html.slim new file mode 100644 index 0000000000..1323c49d52 --- /dev/null +++ b/app/views/publishers/settings/index.html.slim @@ -0,0 +1,20 @@ +.single-panel--wrapper.single-panel--wrapper--large.single-panel--wrapper--short + .single-panel--padded-content--short-padding + .row + .col-left-aligned--content + h5= t ".delete_account.heading" + p= t ".delete_account.intro" + .col-left-aligned--action + p= link_to \ + t(".delete_account.button"), + publisher_path(current_publisher.id), + method: :delete, + class: "btn btn-block btn-danger", + data: { "js-confirm-with-modal": "delete-account-prompt" } + script#delete-account-prompt type="text/html" + h4= t ".delete_account.prompt.header" + p= t ".delete_account.prompt.final_confirmation" + .modal-buttons + = link_to t(".delete_account.prompt.deny"), "#", class: "js-deny btn btn-wide btn-outline-secondary" + = link_to t(".delete_account.prompt.confirm"), "#", class: "js-confirm btn btn-wide btn-danger" + diff --git a/app/views/totp_registrations/new.html.slim b/app/views/totp_registrations/new.html.slim index 0d54a5476c..8c3e41f65d 100644 --- a/app/views/totp_registrations/new.html.slim +++ b/app/views/totp_registrations/new.html.slim @@ -38,4 +38,4 @@ .col-halves .col-half= f.submit t(".submit_value"), class: "btn btn-primary", :"data-piwik-action" => "TOTPLoginClicked", :"data-piwik-name" => "Clicked", :"data-piwik-value" => "Authentication" - .col-half.text-right= link_to t("shared.cancel"), two_factor_registrations_path, class: "btn btn-link" + .col-half.text-right= link_to t("shared.cancel"), security_publishers_path, class: "btn btn-link" diff --git a/app/views/u2f_registrations/new.html.slim b/app/views/u2f_registrations/new.html.slim index ce5afb0a7d..79d9950bdb 100644 --- a/app/views/u2f_registrations/new.html.slim +++ b/app/views/u2f_registrations/new.html.slim @@ -67,7 +67,7 @@ .col-half = f.submit t(".submit_value"), class: "btn btn-primary", :"data-piwik-action" => "U2FLoginClicked", :"data-piwik-name" => "Clicked", :"data-piwik-value" => "Authentication" .col-half.text-right - = link_to t("shared.cancel"), two_factor_registrations_path, class: "btn btn-link" + = link_to t("shared.cancel"), security_publishers_path, class: "btn btn-link" .mt-3.js-u2f-is-working h5= t ".waiting_heading" diff --git a/config/application.rb b/config/application.rb index 08c38b48c2..7b4f2b325e 100644 --- a/config/application.rb +++ b/config/application.rb @@ -34,6 +34,10 @@ class Application < Rails::Application config.time_zone = "Pacific Time (US & Canada)" config.active_record.default_timezone = :local + # config.i18n.load_path += Dir[Rails.root.join('config', 'locales', '**', '*.{rb,yml}')] +# config.i18n.load_path += Dir["#{Rails.root.to_s}/config/locales/**/*.{rb,yml}"] +# config.i18n.default_locale = :en + # Let's ensure that our generators make a UUID as default config.generators do |generator| diff --git a/config/environments/development.rb b/config/environments/development.rb index 89bd9fbe70..0bf22c5f36 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -66,6 +66,8 @@ # Suppress logger output for asset requests. config.assets.quiet = true + config.i18n.load_path += Dir["#{Rails.root.to_s}/config/locales/**/*.{rb,yml}"] + config.i18n.default_locale = :en # Raises error for missing translations config.action_view.raise_on_missing_translations = true diff --git a/config/i18n-tasks.yml b/config/i18n-tasks.yml index 3fdcb7a8f6..98e837fcc4 100644 --- a/config/i18n-tasks.yml +++ b/config/i18n-tasks.yml @@ -15,25 +15,27 @@ data: # Locale files or `File.find` patterns where translations are read from: read: - # Default: - - config/locales/%{locale}.yml - + ## Default: + # - config/locales/%{locale}.yml ## More files: # - config/locales/**/*.%{locale}.yml - # Another gem (replace %#= with %=): - - "<%= %x[bundle show recaptcha].chomp %>/templates/locales/%{locale}.yml" # Locale files to write new keys to, based on a list of key pattern => file rules. Matched from top to bottom: # `i18n-tasks normalize -p` will force move the keys according to these rules write: - # For example, write devise and simple form keys to their respective files: - - ['{devise}.*', 'config/locales/\1.%{locale}.yml'] - + ## For example, write devise and simple form keys to their respective files: + # - ['{devise, simple_form}.*', 'config/locales/\1.%{locale}.yml'] ## Catch-all default: # - config/locales/%{locale}.yml + # External locale data (e.g. gems). + # This data is not considered unused and is never written to. + external: + ## Example (replace %#= with %=): + # - "<%#= %x[bundle show vagrant].chomp %>/templates/locales/%{locale}.yml" + ## Specify the router (see Readme for details). Valid values: conservative_router, pattern_router, or a custom class. - # router: convervative_router + # router: conservative_router yaml: write: @@ -80,10 +82,14 @@ search: ## The options specified above are passed down to each scanner. Per-scanner options can be specified as well. ## See this example of a custom scanner: https://github.com/glebm/i18n-tasks/wiki/A-custom-scanner-example -## Google Translate +## Translation Services # translation: +# # Google Translate # # Get an API key and set billing info at https://code.google.com/apis/console to use Google Translate -# api_key: "AbC-dEf5" +# google_translate_api_key: "AbC-dEf5" +# # DeepL Pro Translate +# # Get an API key and subscription at https://www.deepl.com/pro to use DeepL Pro +# deepl_api_key: "48E92789-57A3-466A-9959-1A1A1A1A1A1A" ## Do not consider these keys missing: # ignore_missing: @@ -91,8 +97,8 @@ search: # - '{devise,simple_form}.*' ## Consider these keys used: - ignore_unused: - - 'activerecord.attributes.*' +# ignore_unused: +# - 'activerecord.attributes.*' # - '{devise,kaminari,will_paginate}.*' # - 'simple_form.{yes,no}' # - 'simple_form.{placeholders,hints,labels}.*' @@ -105,6 +111,10 @@ search: # fr,es: # - common.brand +## Exclude these keys from the `i18n-tasks check-consistent-interpolations` report: +# ignore_inconsistent_interpolations: +# - 'activerecord.attributes.*' + ## Ignore these keys completely: # ignore: # - kaminari.* diff --git a/config/initializers/locale.rb b/config/initializers/locale.rb new file mode 100644 index 0000000000..b8f685fa6f --- /dev/null +++ b/config/initializers/locale.rb @@ -0,0 +1,3 @@ +I18n.load_path += Dir["#{Rails.root.to_s}/config/locales/**/*.yml"] +I18n.default_locale = :en + diff --git a/config/locales/en.yml b/config/locales/en.yml index a1eea28f64..ab44562692 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -85,6 +85,7 @@ en: nav: security: Security + settings: Settings log_out: Log Out help: Help faqs: FAQs @@ -983,80 +984,6 @@ en: lost_2fa_link: We can help. lost_2fa_note_html: | For information related to account settings, visit our Help Center. - - two_factor_registrations: - index: - heading: Two-factor Authentication - intro: | - Two-factor authentication (2FA) is a method of confirming your identity - by using two different forms of verification when you access Brave - Payments in order to increase security (recommended for protecting your - account). - enabled_yes: Enabled - enabled_no: Not enabled - totp: - heading: App on your phone - intro: | - Use an app on your phone to get an authentication code. - You will be asked to type in this code when logging in. - enabled: Authenticator app has been set up - disabled: Authenticator app has not been set up - disabled_without_fallback_html: | - Recommended: Set up an authenticator as - the secondary 2FA in case you run into a problem with the security - key. - reconfigure: Reconfigure - button: Set up - destroy: Disable - confirm_disable: - header: Disable Authenticator App? - intro: "Your remaining two-factor authentication method:" - none: None - no_totp_warning: | - Authenticator app provides a good fallback method to log - in to your account securely in the case that you lose the - hardware security key. - no_2fa_warning_html: | - Disabling authenticator app will effectively - turn off the two-factor authentication - for your account. - final_confirmation: | - Are you sure you want to disable authenticator app? - deny: Do Not Disable - confirm: Disable it for now - name_default: Anonymous Key - u2f: - heading: Hardware security keys - intro: | - Security key is a small device that connects to your computer via a - USB port and works with FIDO Universal 2nd Factor (U2F). - You will be asked to insert and press the key instead of typing in a - code. - intro_warning: | - Currently, security key is supported by Google Chrome and Opera. - browser: - heading: Limited Browser Support - content_html: | - This means you will need to update to the latest Brave, Google - Chrome or Opera in order to set up and - log in using security keys. More browsers will start supporting the - security key in the near future. We will inform you on the changes. - device: - tooltip: A list of security keys that have been tested - heading: Tested Security Keys - content_html: | - The following products have been tested and proven to work with our - system:
- - YubiKey
- - Ledger Blue - disabled: No keys have been added - button: Add Key - prompt: - heading: Protect your account - subheading: by enabling two-factor authentication - intro: This added security is recommended for making sure it's really you logging in to your account. - skip: Skip for now - setup: Set Up 2FA totp_registrations: new: heading: Set Up Authenticator App @@ -1067,52 +994,3 @@ en: step_3: Enter the 6-digit code from the app once the scan is complete. password_prompt: 6-digit code submit_value: Complete - u2f_registrations: - new: - heading: Register Security Key - name_placeholder: Enter a nickname for the key - submit_value: Add - waiting_heading: Waiting for your security key... - waiting_description: | - Insert the new hardware key into your computer and press the button when - it's blinking. - u2f-unavailable: | - Your browser doesn't look like it supports U2F, the two factor auth - platform supported by Brave. Please use the latest version of Brave, Chrome - or Opera to register your U2F-compatible device, for example a YubiKey. - u2f-error: - bad-request: | - There was an unexpected error in the registration request made by - Brave. Please reload this page and re-attempt registration. - (BAD_REQUEST) - configuration-unsupported: | - Client configuration is not supported. (CONFIGURATION_UNSUPPORTED) - device-ineligible: | - The presented security key is not eligible for registration. This may mean - that the token is already registered. (DEVICE_INELIGIBLE) - other-error: | - There was an unexpected error registering your security key. Re-attempting - registration may resolve this issue. (OTHER_ERROR) - timeout: | - There was an unexpected timeout waiting for your security key to respond to - the registration request. Please re-attempt registration and activate - the security key when it is blinking. (TIMEOUT) - implementation-incomplete: | - Please insert your security key and re-attempt registration. Some - browsers have an incomplete implementation of this - protocol. Please use a current release of Brave, Google Chrome or Opera. - (IMPLEMENTATION_INCOMPLETE) - u2f_registration: - name_default: Anonymous Key - confirm_disable: - header: Remove Security Key? - intro: "Your remaining two-factor authentication method:" - remaining_totp: Authenticator app on your phone - none: None - no_2fa_warning_html: | - Removing this security key will effectively - turn off the two-factor authentication - for your account. - final_confirmation: Are you sure you want to remove this security key? - deny: Do Not Remove - confirm: Remove Security Key diff --git a/config/locales/views/publishers/security/en.yml b/config/locales/views/publishers/security/en.yml new file mode 100644 index 0000000000..dc2971e7a9 --- /dev/null +++ b/config/locales/views/publishers/security/en.yml @@ -0,0 +1,75 @@ +en: + publishers: + security: + prompt: + heading: Protect your account + subheading: by enabling two-factor authentication + intro: This added security is recommended for making sure it's really you logging in to your account. + skip: Skip for now + setup: Set Up 2FA + index: + heading: Two-factor Authentication + intro: | + Two-factor authentication (2FA) is a method of confirming your identity + by using two different forms of verification when you access Brave + Payments in order to increase security (recommended for protecting your + account). + enabled_yes: Enabled + enabled_no: Not enabled + totp: + heading: App on your phone + intro: | + Use an app on your phone to get an authentication code. + You will be asked to type in this code when logging in. + enabled: Authenticator app has been set up + disabled: Authenticator app has not been set up + disabled_without_fallback_html: | + Recommended: Set up an authenticator as + the secondary 2FA in case you run into a problem with the security + key. + reconfigure: Reconfigure + button: Set up + destroy: Disable + confirm_disable: + header: Disable Authenticator App? + intro: "Your remaining two-factor authentication method:" + none: None + no_totp_warning: | + Authenticator app provides a good fallback method to log + in to your account securely in the case that you lose the + hardware security key. + no_2fa_warning_html: | + Disabling authenticator app will effectively + turn off the two-factor authentication + for your account. + final_confirmation: | + Are you sure you want to disable authenticator app? + deny: Do Not Disable + confirm: Disable it for now + name_default: Anonymous Key + u2f: + heading: Hardware security keys + intro: | + Security key is a small device that connects to your computer via a + USB port and works with FIDO Universal 2nd Factor (U2F). + You will be asked to insert and press the key instead of typing in a + code. + intro_warning: | + Currently, security key is supported by Brave, Google Chrome, and Opera. + browser: + heading: Limited Browser Support + content_html: | + This means you will need to update to the latest Brave, Google + Chrome or Opera in order to set up and + log in using security keys. More browsers will start supporting the + security key in the near future. We will inform you on the changes. + device: + tooltip: A list of security keys that have been tested + heading: Tested Security Keys + content_html: | + The following products have been tested and proven to work with our + system:
+ - YubiKey
+ - Ledger Blue + disabled: No keys have been added + button: Add Key diff --git a/config/locales/views/publishers/settings/en.yml b/config/locales/views/publishers/settings/en.yml new file mode 100644 index 0000000000..7b9be65364 --- /dev/null +++ b/config/locales/views/publishers/settings/en.yml @@ -0,0 +1,15 @@ +en: + publishers: + settings: + index: + delete_account: + heading: Account Deletion + intro: | + We'll disconnect your channels and wipe all personally identifiable information + from our databases and connected providers. + button: Delete + prompt: + header: Are you sure you want to delete your account? + final_confirmation: It'll take a few minutes for the purge to complete. + deny: No, keep my account active + confirm: Yes, I'm certain diff --git a/config/locales/views/u2f_registrations/en.yml b/config/locales/views/u2f_registrations/en.yml new file mode 100644 index 0000000000..2751afc623 --- /dev/null +++ b/config/locales/views/u2f_registrations/en.yml @@ -0,0 +1,50 @@ +en: + u2f_registrations: + new: + heading: Register Security Key + name_placeholder: Enter a nickname for the key + submit_value: Add + waiting_heading: Waiting for your security key... + waiting_description: | + Insert the new hardware key into your computer and press the button when + it's blinking. + u2f-unavailable: | + Your browser doesn't look like it supports U2F, the two factor auth + platform supported by Brave. Please use the latest version of Brave, Chrome + or Opera to register your U2F-compatible device, for example a YubiKey. + u2f-error: + bad-request: | + There was an unexpected error in the registration request made by + Brave. Please reload this page and re-attempt registration. + (BAD_REQUEST) + configuration-unsupported: | + Client configuration is not supported. (CONFIGURATION_UNSUPPORTED) + device-ineligible: | + The presented security key is not eligible for registration. This may mean + that the token is already registered. (DEVICE_INELIGIBLE) + other-error: | + There was an unexpected error registering your security key. Re-attempting + registration may resolve this issue. (OTHER_ERROR) + timeout: | + There was an unexpected timeout waiting for your security key to respond to + the registration request. Please re-attempt registration and activate + the security key when it is blinking. (TIMEOUT) + implementation-incomplete: | + Please insert your security key and re-attempt registration. Some + browsers have an incomplete implementation of this + protocol. Please use a current release of Brave, Google Chrome or Opera. + (IMPLEMENTATION_INCOMPLETE) + u2f_registration: + name_default: Anonymous Key + confirm_disable: + header: Remove Security Key? + intro: "Your remaining two-factor authentication method:" + remaining_totp: Authenticator app on your phone + none: None + no_2fa_warning_html: | + Removing this security key will effectively + turn off the two-factor authentication + for your account. + final_confirmation: Are you sure you want to remove this security key? + deny: Do Not Remove + confirm: Remove Security Key diff --git a/config/routes.rb b/config/routes.rb index 4bb1db1af7..1b696efc12 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,5 +1,5 @@ Rails.application.routes.draw do - resources :publishers, only: %i(create update new show) do + resources :publishers, only: %i(create update new show destroy) do collection do # Registrations, eventually we should consider refactoring these routes into something a little more restful scope controller: 'registrations', module: 'publishers' do @@ -38,15 +38,13 @@ patch :disconnect_uphold get :choose_new_channel_type get :two_factor_authentication_removal + get :security, to: 'publishers/security#index' + get :prompt_security, to: 'publishers/security#prompt' + get :settings, to: 'publishers/settings#index' post :request_two_factor_authentication_removal get :confirm_two_factor_authentication_removal get :cancel_two_factor_authentication_removal resources :two_factor_authentications, only: %i(index) - resources :two_factor_registrations, only: %i(index) do - collection do - get :prompt - end - end resources :u2f_registrations, only: %i(new create destroy) resources :u2f_authentications, only: %i(create) resources :totp_registrations, only: %i(new create destroy) diff --git a/test/controllers/publishers_controller_test.rb b/test/controllers/publishers_controller_test.rb index 61fc6a7239..a441c92463 100644 --- a/test/controllers/publishers_controller_test.rb +++ b/test/controllers/publishers_controller_test.rb @@ -613,7 +613,7 @@ def request_login_email_uppercase_email(publisher:) sign_in publisher get home_publishers_path - assert_redirected_to prompt_two_factor_registrations_path, "redirects on first visit" + assert_redirected_to prompt_security_publishers_path, "redirects on first visit" follow_redirect! get home_publishers_path diff --git a/test/controllers/totp_registrations_controller_test.rb b/test/controllers/totp_registrations_controller_test.rb index 7780d869e3..13c4d0cbb7 100644 --- a/test/controllers/totp_registrations_controller_test.rb +++ b/test/controllers/totp_registrations_controller_test.rb @@ -47,7 +47,7 @@ class TotpRegistrationsControllerTest < ActionDispatch::IntegrationTest } end - assert_redirected_to two_factor_registrations_path, "redirects to two_factor_registrations" + assert_redirected_to security_publishers_path, "redirects to two_factor_registrations" refute @request.flash[:modal_partial] end @@ -56,7 +56,7 @@ class TotpRegistrationsControllerTest < ActionDispatch::IntegrationTest ROTP::TOTP.any_instance.stubs(:verify_with_drift).returns(true) - get prompt_two_factor_registrations_path + get prompt_security_publishers_path assert_difference("TotpRegistration.count") do post totp_registrations_path, params: { @@ -89,6 +89,6 @@ class TotpRegistrationsControllerTest < ActionDispatch::IntegrationTest } end - assert_redirected_to two_factor_registrations_path, "redirects to two_factor_registrations" + assert_redirected_to security_publishers_path, "redirects to two_factor_registrations" end end diff --git a/test/controllers/two_factor_registrations_controller_test.rb b/test/controllers/two_factor_registrations_controller_test.rb index b14b7b40aa..637243ac2d 100644 --- a/test/controllers/two_factor_registrations_controller_test.rb +++ b/test/controllers/two_factor_registrations_controller_test.rb @@ -9,7 +9,7 @@ class TwoFactorRegistrationsControllerTest < ActionDispatch::IntegrationTest publisher.update_attribute(:totp_registration, totp_registration) sign_in publisher - get two_factor_registrations_path + get security_publishers_path assert_response :success assert_match "Enabled", response.body @@ -23,7 +23,7 @@ class TwoFactorRegistrationsControllerTest < ActionDispatch::IntegrationTest publisher.u2f_registrations << u2f_registration sign_in publisher - get two_factor_registrations_path + get security_publishers_path assert_response :success assert_match u2f_registration.name, response.body @@ -41,7 +41,7 @@ class TwoFactorRegistrationsControllerTest < ActionDispatch::IntegrationTest publisher.u2f_registrations << additional_u2f_registration sign_in publisher - get two_factor_registrations_path + get security_publishers_path assert_response :success assert_match u2f_registration.name, response.body @@ -55,11 +55,11 @@ class TwoFactorRegistrationsControllerTest < ActionDispatch::IntegrationTest publisher = publishers(:completed) sign_in publisher - get prompt_two_factor_registrations_path + get prompt_security_publishers_path assert_response :success assert_select "a[href=?]", home_publishers_path - assert_select "a[href=?]", two_factor_registrations_path + assert_select "a[href=?]", security_publishers_path assert @request.session[:prompted_for_two_factor_registration_at_signup] end diff --git a/test/controllers/u2f_registrations_controller_test.rb b/test/controllers/u2f_registrations_controller_test.rb index 5acbf02660..4d2ec6c3bf 100644 --- a/test/controllers/u2f_registrations_controller_test.rb +++ b/test/controllers/u2f_registrations_controller_test.rb @@ -53,7 +53,7 @@ def canned_u2f_response } end - assert_redirected_to two_factor_registrations_path, "redirects to two_factor_registrations" + assert_redirected_to security_publishers_path, "redirects to two_factor_registrations" refute @request.flash[:modal_partial] end @@ -68,7 +68,7 @@ def canned_u2f_response ) U2fRegistrationsController.any_instance.stubs(:u2f).returns(mock(:register! => mock_u2f_registration)) - get prompt_two_factor_registrations_path + get prompt_security_publishers_path assert_difference("U2fRegistration.count") do post u2f_registrations_path, params: { @@ -93,7 +93,7 @@ def canned_u2f_response sign_in publisher delete u2f_registration_path(u2f_registration) - assert_redirected_to two_factor_registrations_path, "redirects to two_factor_registrations" + assert_redirected_to security_publishers_path, "redirects to two_factor_registrations" follow_redirect! assert_response :success assert_no_match u2f_registration.name, response.body, "page does not show deleted u2f_registration" diff --git a/test/features/sign_up_test.rb b/test/features/sign_up_test.rb index 57a3ee5012..7df0b4ea1c 100644 --- a/test/features/sign_up_test.rb +++ b/test/features/sign_up_test.rb @@ -23,7 +23,7 @@ class SignUpTest < Capybara::Rails::TestCase fill_in "publisher_name", with: name click_button("Sign Up") - assert_current_path(prompt_two_factor_registrations_path) + assert_current_path(prompt_security_publishers_path) click_link("Skip for now") assert_current_path(home_publishers_path) diff --git a/test/features/two_factor_registrations_test.rb b/test/features/two_factor_registrations_test.rb index 7e70b7b109..718feae054 100644 --- a/test/features/two_factor_registrations_test.rb +++ b/test/features/two_factor_registrations_test.rb @@ -7,7 +7,7 @@ class TwoFactorRegistrationsTest < Capybara::Rails::TestCase publisher = publishers(:verified) sign_in publisher - visit two_factor_registrations_path + visit security_publishers_path assert_content page, "Enabled" refute_content page, "Set Up" # TOTP setup is not available @@ -34,7 +34,7 @@ class TwoFactorRegistrationsTest < Capybara::Rails::TestCase publisher = publishers(:verified) sign_in publisher - visit two_factor_registrations_path + visit security_publishers_path assert_content page, "Enabled" assert_content page, "My U2F Key" # Key is present refute_content page, "No keys have been added" # "No key" warning is not visible diff --git a/yarn.lock b/yarn.lock index 738db5e1e2..ff5a8b79e2 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5207,7 +5207,7 @@ is-plain-obj@^1.1.0: resolved "https://registry.yarnpkg.com/is-plain-obj/-/is-plain-obj-1.1.0.tgz#71a50c8429dfca773c92a390a4a03b39fcd51d3e" integrity sha1-caUMhCnfync8kqOQpKA7OfzVHT4= -is-plain-object@^2.0.3, is-plain-object@^2.0.4: +is-plain-object@^2.0.4: version "2.0.4" resolved "https://registry.yarnpkg.com/is-plain-object/-/is-plain-object-2.0.4.tgz#2c163b3fafb1b606d9d17928f05c2a1c38e07677" integrity sha512-h5PpgXkWitc38BBMYawTYMWJHFZJVnBquFE57xFpjB8pJFiF6gZ+bU+WyI/yqXiFR5mdLsgYNaPe8uao6Uv9Og== @@ -9023,15 +9023,12 @@ set-blocking@^2.0.0, set-blocking@~2.0.0: resolved "https://registry.yarnpkg.com/set-blocking/-/set-blocking-2.0.0.tgz#045f9782d011ae9a6803ddd382b24392b3d890f7" integrity sha1-BF+XgtARrppoA93TgrJDkrPYkPc= -set-value@^2.0.0, set-value@^2.0.1: - version "2.0.1" - resolved "https://registry.yarnpkg.com/set-value/-/set-value-2.0.1.tgz#a18d40530e6f07de4228c7defe4227af8cad005b" - integrity sha512-JxHc1weCN68wRY0fhCoXpyK55m/XPHafOmK4UWD7m2CI14GMcFypt4w/0+NV5f/ZMby2F6S2wwA7fgynh9gWSw== +set-value@3.0.1, set-value@^2.0.0, set-value@^2.0.1: + version "3.0.1" + resolved "https://registry.yarnpkg.com/set-value/-/set-value-3.0.1.tgz#52c82af7653ba69eb1db92e81f5cdb32739b9e95" + integrity sha512-w6n3GUPYAWQj4ZyHWzD7K2FnFXHx9OTwJYbWg+6nXjG8sCLfs9DGv+KlqglKIIJx+ks7MlFuwFW2RBPb+8V+xg== dependencies: - extend-shallow "^2.0.1" - is-extendable "^0.1.1" - is-plain-object "^2.0.3" - split-string "^3.0.1" + is-plain-object "^2.0.4" setimmediate@^1.0.4, setimmediate@^1.0.5: version "1.0.5" @@ -9281,7 +9278,7 @@ specificity@^0.4.1: resolved "https://registry.yarnpkg.com/specificity/-/specificity-0.4.1.tgz#aab5e645012db08ba182e151165738d00887b019" integrity sha512-1klA3Gi5PD1Wv9Q0wUoOQN1IWAuPu0D1U03ThXTr0cJ20+/iq2tHSDnK7Kk/0LXJ1ztUB2/1Os0wKmfyNgUQfg== -split-string@^3.0.1, split-string@^3.0.2: +split-string@^3.0.2: version "3.1.0" resolved "https://registry.yarnpkg.com/split-string/-/split-string-3.1.0.tgz#7cb09dda3a86585705c64b39a6466038682e8fe2" integrity sha512-NzNVhJDYpwceVVii8/Hu6DKfD2G+NrQHlS/V/qgv763EYudVwEcMQNxd2lh+0VrUByXN/oJkl5grOhYWvQUYiw== From 220403e35e36e8a6dadfbc252d42fde3aec39de7 Mon Sep 17 00:00:00 2001 From: Albert Wang Date: Tue, 30 Jul 2019 11:57:36 -0700 Subject: [PATCH 9/9] Revert "Feature: Delete account (#2058)" (#2083) This reverts commit 432fa6ed52a537f04f9b65e37d2b64e96208b777. --- app/assets/stylesheets/theme/columns.scss | 2 +- app/assets/stylesheets/theme/panels.scss | 10 +- .../concerns/two_factor_registration.rb | 2 +- .../publishers/security_controller.rb | 18 --- .../publishers/settings_controller.rb | 8 -- app/controllers/publishers_controller.rb | 8 +- .../totp_registrations_controller.rb | 2 +- .../two_factor_registrations_controller.rb | 16 +++ .../u2f_registrations_controller.rb | 2 +- app/javascript/components/navbar/Navbar.tsx | 5 - app/javascript/locale/en.ts | 3 +- app/javascript/routes/routes.ts | 3 - app/views/application/_nav.html.slim | 3 +- app/views/publishers/settings/index.html.slim | 20 --- app/views/totp_registrations/new.html.slim | 2 +- .../index.html.slim | 15 +-- .../prompt.html.slim | 2 +- app/views/u2f_registrations/new.html.slim | 2 +- config/application.rb | 4 - config/environments/development.rb | 2 - config/i18n-tasks.yml | 36 ++--- config/initializers/locale.rb | 3 - config/locales/en.yml | 124 +++++++++++++++++- .../locales/views/publishers/security/en.yml | 75 ----------- .../locales/views/publishers/settings/en.yml | 15 --- config/locales/views/u2f_registrations/en.yml | 50 ------- config/routes.rb | 10 +- .../controllers/publishers_controller_test.rb | 2 +- .../totp_registrations_controller_test.rb | 6 +- ...wo_factor_registrations_controller_test.rb | 10 +- .../u2f_registrations_controller_test.rb | 6 +- test/features/sign_up_test.rb | 2 +- .../features/two_factor_registrations_test.rb | 4 +- yarn.lock | 17 ++- 34 files changed, 201 insertions(+), 288 deletions(-) delete mode 100644 app/controllers/publishers/security_controller.rb delete mode 100644 app/controllers/publishers/settings_controller.rb create mode 100644 app/controllers/two_factor_registrations_controller.rb delete mode 100644 app/views/publishers/settings/index.html.slim rename app/views/{publishers/security => two_factor_registrations}/index.html.slim (91%) rename app/views/{publishers/security => two_factor_registrations}/prompt.html.slim (81%) delete mode 100644 config/initializers/locale.rb delete mode 100644 config/locales/views/publishers/security/en.yml delete mode 100644 config/locales/views/publishers/settings/en.yml delete mode 100644 config/locales/views/u2f_registrations/en.yml diff --git a/app/assets/stylesheets/theme/columns.scss b/app/assets/stylesheets/theme/columns.scss index 01816a93ff..3418d99f5d 100644 --- a/app/assets/stylesheets/theme/columns.scss +++ b/app/assets/stylesheets/theme/columns.scss @@ -62,7 +62,7 @@ } } -.col-left-aligned { +.col-two-factor { &--content { @include make-col-ready(); text-align: left; diff --git a/app/assets/stylesheets/theme/panels.scss b/app/assets/stylesheets/theme/panels.scss index dbbd4a36d5..4df5e7f2b4 100644 --- a/app/assets/stylesheets/theme/panels.scss +++ b/app/assets/stylesheets/theme/panels.scss @@ -9,7 +9,7 @@ $brave-panels-borderRadius: 8px; max-width: $spacer * 40; min-height: $spacer * 32; margin: 0 auto; - padding: 0 10px; + padding: 0 15px; display: flex; flex-direction: column; @@ -21,10 +21,6 @@ $brave-panels-borderRadius: 8px; min-height: $spacer * 10; } - &--short { - min-height: $spacer * 8; - } - &--medium { max-width: $spacer * 45; } @@ -138,10 +134,6 @@ $brave-panels-borderRadius: 8px; margin-top: auto; margin-bottom: auto; - &--short-padding { - padding: $spacer * 3 $spacer * 2; - } - &--email-sent { padding-top: 125px; margin-top: 30px; diff --git a/app/controllers/concerns/two_factor_registration.rb b/app/controllers/concerns/two_factor_registration.rb index fc5f139294..1eeab12e97 100644 --- a/app/controllers/concerns/two_factor_registration.rb +++ b/app/controllers/concerns/two_factor_registration.rb @@ -15,7 +15,7 @@ def handle_redirect_after_2fa_registration end end - redirect_to security_publishers_path + redirect_to two_factor_registrations_path end def flag_2fa_registration_during_signup diff --git a/app/controllers/publishers/security_controller.rb b/app/controllers/publishers/security_controller.rb deleted file mode 100644 index 5aae84d4b1..0000000000 --- a/app/controllers/publishers/security_controller.rb +++ /dev/null @@ -1,18 +0,0 @@ -require "concerns/two_factor_registration" - -module Publishers - class SecurityController < ApplicationController - include PublishersHelper - include TwoFactorRegistration - - before_action :authenticate_publisher! - - def index - @u2f_registrations = current_publisher.u2f_registrations - end - - def prompt - flag_2fa_registration_during_signup - end - end -end diff --git a/app/controllers/publishers/settings_controller.rb b/app/controllers/publishers/settings_controller.rb deleted file mode 100644 index b0745f4912..0000000000 --- a/app/controllers/publishers/settings_controller.rb +++ /dev/null @@ -1,8 +0,0 @@ -module Publishers - class SettingsController < ApplicationController - before_action :authenticate_publisher! - - def index - end - end -end diff --git a/app/controllers/publishers_controller.rb b/app/controllers/publishers_controller.rb index 4a4e98ccb7..01ddc125e3 100644 --- a/app/controllers/publishers_controller.rb +++ b/app/controllers/publishers_controller.rb @@ -270,12 +270,6 @@ def show redirect_to(publisher_next_step_path(current_publisher)) end - def destroy - PublisherRemovalJob.perform_later(publisher_id: current_publisher.id) - sign_out(current_publisher) - redirect_to(root_path) - end - def redirect_if_suspended # Redirect to suspended page if they're logged in redirect_to(suspended_error_publishers_path) and return if current_publisher.present? && current_publisher.suspended? @@ -448,7 +442,7 @@ def require_publisher_email_verified_through_youtube_auth def prompt_for_two_factor_setup return if current_publisher.two_factor_prompted_at.present? || two_factor_enabled?(current_publisher) current_publisher.update! two_factor_prompted_at: Time.now - redirect_to prompt_security_publishers_path + redirect_to prompt_two_factor_registrations_path end def update_sendgrid(publisher:, prior_email: nil) diff --git a/app/controllers/totp_registrations_controller.rb b/app/controllers/totp_registrations_controller.rb index 2f70a8f77c..79a7cd01c2 100644 --- a/app/controllers/totp_registrations_controller.rb +++ b/app/controllers/totp_registrations_controller.rb @@ -29,7 +29,7 @@ def create def destroy current_publisher.totp_registration.destroy! if current_publisher.totp_registration.present? - redirect_to security_publishers_path + redirect_to two_factor_registrations_path end private diff --git a/app/controllers/two_factor_registrations_controller.rb b/app/controllers/two_factor_registrations_controller.rb new file mode 100644 index 0000000000..8dee9fc961 --- /dev/null +++ b/app/controllers/two_factor_registrations_controller.rb @@ -0,0 +1,16 @@ +require "concerns/two_factor_registration" + +class TwoFactorRegistrationsController < ApplicationController + include PublishersHelper + include TwoFactorRegistration + + before_action :authenticate_publisher! + + def index + @u2f_registrations = current_publisher.u2f_registrations + end + + def prompt + flag_2fa_registration_during_signup + end +end diff --git a/app/controllers/u2f_registrations_controller.rb b/app/controllers/u2f_registrations_controller.rb index 19bcf0ff4b..77064d819c 100644 --- a/app/controllers/u2f_registrations_controller.rb +++ b/app/controllers/u2f_registrations_controller.rb @@ -48,7 +48,7 @@ def destroy u2f_registration = current_publisher.u2f_registrations.find(params[:id]) u2f_registration.destroy - redirect_to security_publishers_path + redirect_to two_factor_registrations_path end end diff --git a/app/javascript/components/navbar/Navbar.tsx b/app/javascript/components/navbar/Navbar.tsx index 26f6560cea..d676ffd60c 100644 --- a/app/javascript/components/navbar/Navbar.tsx +++ b/app/javascript/components/navbar/Navbar.tsx @@ -131,11 +131,6 @@ function Dropdown(props) { > {locale.navbar.security}
- (window.location.href = routes.navbar.settings.path)} - > - {locale.navbar.settings} - (window.location.href = routes.navbar.help.path)} > diff --git a/app/javascript/locale/en.ts b/app/javascript/locale/en.ts index f3d74f147c..0097b663b5 100644 --- a/app/javascript/locale/en.ts +++ b/app/javascript/locale/en.ts @@ -32,8 +32,7 @@ export default { logOut: "Log Out", payments: "Payments", referrals: "Referrals", - security: "Security", - settings: "Settings" + security: "Security" }, notEnoughTokens: "Not enough tokens", off: " ", diff --git a/app/javascript/routes/routes.ts b/app/javascript/routes/routes.ts index 77ee260a21..3dec08feb1 100644 --- a/app/javascript/routes/routes.ts +++ b/app/javascript/routes/routes.ts @@ -37,9 +37,6 @@ export default { }, security: { path: "/publishers/two_factor_registrations" - }, - settings: { - path: "/publishers/settings" } } }; diff --git a/app/views/application/_nav.html.slim b/app/views/application/_nav.html.slim index 09b07a811c..ac8812b248 100644 --- a/app/views/application/_nav.html.slim +++ b/app/views/application/_nav.html.slim @@ -21,13 +21,12 @@ nav.navbar.navbar-default.navbar-static-top.top-nav-collapse .user-name.js-user-name-dropdown= current_publisher.name .user-email= current_publisher.email ul.user-links - li= link_to security_publishers_path do + li= link_to two_factor_registrations_path do span.user-links-lock .user-links-lock-icon= render two_factor_enabled?(current_publisher) ? "locked_svg" : "unlocked_svg" = t ".security" - if show_faq_link? li= link_to t(".faqs"), faqs_path - li= link_to t(".settings"), settings_publishers_path li= link_to t(".help"), "https://support.brave.com/hc/en-us/" li= link_to t(".log_out"), log_out_publishers_path - else diff --git a/app/views/publishers/settings/index.html.slim b/app/views/publishers/settings/index.html.slim deleted file mode 100644 index 1323c49d52..0000000000 --- a/app/views/publishers/settings/index.html.slim +++ /dev/null @@ -1,20 +0,0 @@ -.single-panel--wrapper.single-panel--wrapper--large.single-panel--wrapper--short - .single-panel--padded-content--short-padding - .row - .col-left-aligned--content - h5= t ".delete_account.heading" - p= t ".delete_account.intro" - .col-left-aligned--action - p= link_to \ - t(".delete_account.button"), - publisher_path(current_publisher.id), - method: :delete, - class: "btn btn-block btn-danger", - data: { "js-confirm-with-modal": "delete-account-prompt" } - script#delete-account-prompt type="text/html" - h4= t ".delete_account.prompt.header" - p= t ".delete_account.prompt.final_confirmation" - .modal-buttons - = link_to t(".delete_account.prompt.deny"), "#", class: "js-deny btn btn-wide btn-outline-secondary" - = link_to t(".delete_account.prompt.confirm"), "#", class: "js-confirm btn btn-wide btn-danger" - diff --git a/app/views/totp_registrations/new.html.slim b/app/views/totp_registrations/new.html.slim index 8c3e41f65d..0d54a5476c 100644 --- a/app/views/totp_registrations/new.html.slim +++ b/app/views/totp_registrations/new.html.slim @@ -38,4 +38,4 @@ .col-halves .col-half= f.submit t(".submit_value"), class: "btn btn-primary", :"data-piwik-action" => "TOTPLoginClicked", :"data-piwik-name" => "Clicked", :"data-piwik-value" => "Authentication" - .col-half.text-right= link_to t("shared.cancel"), security_publishers_path, class: "btn btn-link" + .col-half.text-right= link_to t("shared.cancel"), two_factor_registrations_path, class: "btn btn-link" diff --git a/app/views/publishers/security/index.html.slim b/app/views/two_factor_registrations/index.html.slim similarity index 91% rename from app/views/publishers/security/index.html.slim rename to app/views/two_factor_registrations/index.html.slim index 40518b8740..8363bde354 100644 --- a/app/views/publishers/security/index.html.slim +++ b/app/views/two_factor_registrations/index.html.slim @@ -2,17 +2,17 @@ .single-panel--content .single-panel--padded-content .row - .col-left-aligned--content + .col-two-factor--content h3.single-panel--headline= t ".heading" p= t ".intro" - .col-left-aligned--action.two-factor-enabled-status + .col-two-factor--action.two-factor-enabled-status - if two_factor_enabled?(current_publisher) span.two-factor-enabled= t ".enabled_yes" - else span.two-factor-disabled= t ".enabled_no" br - .col-left-aligned--content + .col-two-factor--content h5= t ".totp.heading" p= t ".totp.intro" - if totp_enabled?(current_publisher) @@ -32,7 +32,7 @@ p.two-factor-method-disabled == "• " = t ".totp.disabled" - .col-left-aligned--action + .col-two-factor--action - if totp_enabled?(current_publisher) p= link_to \ t(".totp.destroy"), @@ -68,7 +68,7 @@ p= link_to t(".totp.button"), new_totp_registration_path, class: "btn btn-block btn-primary", :"data-piwik-action" => "CreateTOTPClicked", :"data-piwik-name" => "Clicked", :"data-piwik-value" => "2FA" p.icon= render "smartphone_with_code" - .col-left-aligned--content + .col-two-factor--content h5= t ".u2f.heading" p = t ".u2f.intro" @@ -89,12 +89,11 @@ span.tf-tooltip-content-heading= t ".u2f.device.heading" span.tf-tooltip-content-content== t ".u2f.device.content_html" - if @u2f_registrations.any? - - @u2f_registrations.each do |u2f_registration| - = render partial: "u2f_registrations/u2f_registration", locals: { u2f_registration: u2f_registration } + p= render @u2f_registrations - else p.two-factor-method-disabled == "• " = t ".u2f.disabled" - .col-left-aligned--action + .col-two-factor--action p= link_to t(".u2f.button"), new_u2f_registration_path, class: "btn btn-block btn-primary", :"data-piwik-action" => "CreateU2FClicked", :"data-piwik-name" => "Clicked", :"data-piwik-value" => "2FA" p.icon= render "usb" diff --git a/app/views/publishers/security/prompt.html.slim b/app/views/two_factor_registrations/prompt.html.slim similarity index 81% rename from app/views/publishers/security/prompt.html.slim rename to app/views/two_factor_registrations/prompt.html.slim index a59c7cdeff..4fe0e126a0 100644 --- a/app/views/publishers/security/prompt.html.slim +++ b/app/views/two_factor_registrations/prompt.html.slim @@ -15,4 +15,4 @@ .col-buttons-half = link_to t(".skip"), home_publishers_path, class: "btn btn-link-primary btn-block" .col-buttons-half - = link_to t(".setup"), security_publishers_path, class: "btn btn-primary btn-block" + = link_to t(".setup"), two_factor_registrations_path, class: "btn btn-primary btn-block" diff --git a/app/views/u2f_registrations/new.html.slim b/app/views/u2f_registrations/new.html.slim index 79d9950bdb..ce5afb0a7d 100644 --- a/app/views/u2f_registrations/new.html.slim +++ b/app/views/u2f_registrations/new.html.slim @@ -67,7 +67,7 @@ .col-half = f.submit t(".submit_value"), class: "btn btn-primary", :"data-piwik-action" => "U2FLoginClicked", :"data-piwik-name" => "Clicked", :"data-piwik-value" => "Authentication" .col-half.text-right - = link_to t("shared.cancel"), security_publishers_path, class: "btn btn-link" + = link_to t("shared.cancel"), two_factor_registrations_path, class: "btn btn-link" .mt-3.js-u2f-is-working h5= t ".waiting_heading" diff --git a/config/application.rb b/config/application.rb index 7b4f2b325e..08c38b48c2 100644 --- a/config/application.rb +++ b/config/application.rb @@ -34,10 +34,6 @@ class Application < Rails::Application config.time_zone = "Pacific Time (US & Canada)" config.active_record.default_timezone = :local - # config.i18n.load_path += Dir[Rails.root.join('config', 'locales', '**', '*.{rb,yml}')] -# config.i18n.load_path += Dir["#{Rails.root.to_s}/config/locales/**/*.{rb,yml}"] -# config.i18n.default_locale = :en - # Let's ensure that our generators make a UUID as default config.generators do |generator| diff --git a/config/environments/development.rb b/config/environments/development.rb index 0bf22c5f36..89bd9fbe70 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -66,8 +66,6 @@ # Suppress logger output for asset requests. config.assets.quiet = true - config.i18n.load_path += Dir["#{Rails.root.to_s}/config/locales/**/*.{rb,yml}"] - config.i18n.default_locale = :en # Raises error for missing translations config.action_view.raise_on_missing_translations = true diff --git a/config/i18n-tasks.yml b/config/i18n-tasks.yml index 98e837fcc4..3fdcb7a8f6 100644 --- a/config/i18n-tasks.yml +++ b/config/i18n-tasks.yml @@ -15,27 +15,25 @@ data: # Locale files or `File.find` patterns where translations are read from: read: - ## Default: - # - config/locales/%{locale}.yml + # Default: + - config/locales/%{locale}.yml + ## More files: # - config/locales/**/*.%{locale}.yml + # Another gem (replace %#= with %=): + - "<%= %x[bundle show recaptcha].chomp %>/templates/locales/%{locale}.yml" # Locale files to write new keys to, based on a list of key pattern => file rules. Matched from top to bottom: # `i18n-tasks normalize -p` will force move the keys according to these rules write: - ## For example, write devise and simple form keys to their respective files: - # - ['{devise, simple_form}.*', 'config/locales/\1.%{locale}.yml'] + # For example, write devise and simple form keys to their respective files: + - ['{devise}.*', 'config/locales/\1.%{locale}.yml'] + ## Catch-all default: # - config/locales/%{locale}.yml - # External locale data (e.g. gems). - # This data is not considered unused and is never written to. - external: - ## Example (replace %#= with %=): - # - "<%#= %x[bundle show vagrant].chomp %>/templates/locales/%{locale}.yml" - ## Specify the router (see Readme for details). Valid values: conservative_router, pattern_router, or a custom class. - # router: conservative_router + # router: convervative_router yaml: write: @@ -82,14 +80,10 @@ search: ## The options specified above are passed down to each scanner. Per-scanner options can be specified as well. ## See this example of a custom scanner: https://github.com/glebm/i18n-tasks/wiki/A-custom-scanner-example -## Translation Services +## Google Translate # translation: -# # Google Translate # # Get an API key and set billing info at https://code.google.com/apis/console to use Google Translate -# google_translate_api_key: "AbC-dEf5" -# # DeepL Pro Translate -# # Get an API key and subscription at https://www.deepl.com/pro to use DeepL Pro -# deepl_api_key: "48E92789-57A3-466A-9959-1A1A1A1A1A1A" +# api_key: "AbC-dEf5" ## Do not consider these keys missing: # ignore_missing: @@ -97,8 +91,8 @@ search: # - '{devise,simple_form}.*' ## Consider these keys used: -# ignore_unused: -# - 'activerecord.attributes.*' + ignore_unused: + - 'activerecord.attributes.*' # - '{devise,kaminari,will_paginate}.*' # - 'simple_form.{yes,no}' # - 'simple_form.{placeholders,hints,labels}.*' @@ -111,10 +105,6 @@ search: # fr,es: # - common.brand -## Exclude these keys from the `i18n-tasks check-consistent-interpolations` report: -# ignore_inconsistent_interpolations: -# - 'activerecord.attributes.*' - ## Ignore these keys completely: # ignore: # - kaminari.* diff --git a/config/initializers/locale.rb b/config/initializers/locale.rb deleted file mode 100644 index b8f685fa6f..0000000000 --- a/config/initializers/locale.rb +++ /dev/null @@ -1,3 +0,0 @@ -I18n.load_path += Dir["#{Rails.root.to_s}/config/locales/**/*.yml"] -I18n.default_locale = :en - diff --git a/config/locales/en.yml b/config/locales/en.yml index ab44562692..a1eea28f64 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -85,7 +85,6 @@ en: nav: security: Security - settings: Settings log_out: Log Out help: Help faqs: FAQs @@ -984,6 +983,80 @@ en: lost_2fa_link: We can help. lost_2fa_note_html: | For information related to account settings, visit our Help Center. + + two_factor_registrations: + index: + heading: Two-factor Authentication + intro: | + Two-factor authentication (2FA) is a method of confirming your identity + by using two different forms of verification when you access Brave + Payments in order to increase security (recommended for protecting your + account). + enabled_yes: Enabled + enabled_no: Not enabled + totp: + heading: App on your phone + intro: | + Use an app on your phone to get an authentication code. + You will be asked to type in this code when logging in. + enabled: Authenticator app has been set up + disabled: Authenticator app has not been set up + disabled_without_fallback_html: | + Recommended: Set up an authenticator as + the secondary 2FA in case you run into a problem with the security + key. + reconfigure: Reconfigure + button: Set up + destroy: Disable + confirm_disable: + header: Disable Authenticator App? + intro: "Your remaining two-factor authentication method:" + none: None + no_totp_warning: | + Authenticator app provides a good fallback method to log + in to your account securely in the case that you lose the + hardware security key. + no_2fa_warning_html: | + Disabling authenticator app will effectively + turn off the two-factor authentication + for your account. + final_confirmation: | + Are you sure you want to disable authenticator app? + deny: Do Not Disable + confirm: Disable it for now + name_default: Anonymous Key + u2f: + heading: Hardware security keys + intro: | + Security key is a small device that connects to your computer via a + USB port and works with FIDO Universal 2nd Factor (U2F). + You will be asked to insert and press the key instead of typing in a + code. + intro_warning: | + Currently, security key is supported by Google Chrome and Opera. + browser: + heading: Limited Browser Support + content_html: | + This means you will need to update to the latest Brave, Google + Chrome or Opera in order to set up and + log in using security keys. More browsers will start supporting the + security key in the near future. We will inform you on the changes. + device: + tooltip: A list of security keys that have been tested + heading: Tested Security Keys + content_html: | + The following products have been tested and proven to work with our + system:
+ - YubiKey
+ - Ledger Blue + disabled: No keys have been added + button: Add Key + prompt: + heading: Protect your account + subheading: by enabling two-factor authentication + intro: This added security is recommended for making sure it's really you logging in to your account. + skip: Skip for now + setup: Set Up 2FA totp_registrations: new: heading: Set Up Authenticator App @@ -994,3 +1067,52 @@ en: step_3: Enter the 6-digit code from the app once the scan is complete. password_prompt: 6-digit code submit_value: Complete + u2f_registrations: + new: + heading: Register Security Key + name_placeholder: Enter a nickname for the key + submit_value: Add + waiting_heading: Waiting for your security key... + waiting_description: | + Insert the new hardware key into your computer and press the button when + it's blinking. + u2f-unavailable: | + Your browser doesn't look like it supports U2F, the two factor auth + platform supported by Brave. Please use the latest version of Brave, Chrome + or Opera to register your U2F-compatible device, for example a YubiKey. + u2f-error: + bad-request: | + There was an unexpected error in the registration request made by + Brave. Please reload this page and re-attempt registration. + (BAD_REQUEST) + configuration-unsupported: | + Client configuration is not supported. (CONFIGURATION_UNSUPPORTED) + device-ineligible: | + The presented security key is not eligible for registration. This may mean + that the token is already registered. (DEVICE_INELIGIBLE) + other-error: | + There was an unexpected error registering your security key. Re-attempting + registration may resolve this issue. (OTHER_ERROR) + timeout: | + There was an unexpected timeout waiting for your security key to respond to + the registration request. Please re-attempt registration and activate + the security key when it is blinking. (TIMEOUT) + implementation-incomplete: | + Please insert your security key and re-attempt registration. Some + browsers have an incomplete implementation of this + protocol. Please use a current release of Brave, Google Chrome or Opera. + (IMPLEMENTATION_INCOMPLETE) + u2f_registration: + name_default: Anonymous Key + confirm_disable: + header: Remove Security Key? + intro: "Your remaining two-factor authentication method:" + remaining_totp: Authenticator app on your phone + none: None + no_2fa_warning_html: | + Removing this security key will effectively + turn off the two-factor authentication + for your account. + final_confirmation: Are you sure you want to remove this security key? + deny: Do Not Remove + confirm: Remove Security Key diff --git a/config/locales/views/publishers/security/en.yml b/config/locales/views/publishers/security/en.yml deleted file mode 100644 index dc2971e7a9..0000000000 --- a/config/locales/views/publishers/security/en.yml +++ /dev/null @@ -1,75 +0,0 @@ -en: - publishers: - security: - prompt: - heading: Protect your account - subheading: by enabling two-factor authentication - intro: This added security is recommended for making sure it's really you logging in to your account. - skip: Skip for now - setup: Set Up 2FA - index: - heading: Two-factor Authentication - intro: | - Two-factor authentication (2FA) is a method of confirming your identity - by using two different forms of verification when you access Brave - Payments in order to increase security (recommended for protecting your - account). - enabled_yes: Enabled - enabled_no: Not enabled - totp: - heading: App on your phone - intro: | - Use an app on your phone to get an authentication code. - You will be asked to type in this code when logging in. - enabled: Authenticator app has been set up - disabled: Authenticator app has not been set up - disabled_without_fallback_html: | - Recommended: Set up an authenticator as - the secondary 2FA in case you run into a problem with the security - key. - reconfigure: Reconfigure - button: Set up - destroy: Disable - confirm_disable: - header: Disable Authenticator App? - intro: "Your remaining two-factor authentication method:" - none: None - no_totp_warning: | - Authenticator app provides a good fallback method to log - in to your account securely in the case that you lose the - hardware security key. - no_2fa_warning_html: | - Disabling authenticator app will effectively - turn off the two-factor authentication - for your account. - final_confirmation: | - Are you sure you want to disable authenticator app? - deny: Do Not Disable - confirm: Disable it for now - name_default: Anonymous Key - u2f: - heading: Hardware security keys - intro: | - Security key is a small device that connects to your computer via a - USB port and works with FIDO Universal 2nd Factor (U2F). - You will be asked to insert and press the key instead of typing in a - code. - intro_warning: | - Currently, security key is supported by Brave, Google Chrome, and Opera. - browser: - heading: Limited Browser Support - content_html: | - This means you will need to update to the latest Brave, Google - Chrome or Opera in order to set up and - log in using security keys. More browsers will start supporting the - security key in the near future. We will inform you on the changes. - device: - tooltip: A list of security keys that have been tested - heading: Tested Security Keys - content_html: | - The following products have been tested and proven to work with our - system:
- - YubiKey
- - Ledger Blue - disabled: No keys have been added - button: Add Key diff --git a/config/locales/views/publishers/settings/en.yml b/config/locales/views/publishers/settings/en.yml deleted file mode 100644 index 7b9be65364..0000000000 --- a/config/locales/views/publishers/settings/en.yml +++ /dev/null @@ -1,15 +0,0 @@ -en: - publishers: - settings: - index: - delete_account: - heading: Account Deletion - intro: | - We'll disconnect your channels and wipe all personally identifiable information - from our databases and connected providers. - button: Delete - prompt: - header: Are you sure you want to delete your account? - final_confirmation: It'll take a few minutes for the purge to complete. - deny: No, keep my account active - confirm: Yes, I'm certain diff --git a/config/locales/views/u2f_registrations/en.yml b/config/locales/views/u2f_registrations/en.yml deleted file mode 100644 index 2751afc623..0000000000 --- a/config/locales/views/u2f_registrations/en.yml +++ /dev/null @@ -1,50 +0,0 @@ -en: - u2f_registrations: - new: - heading: Register Security Key - name_placeholder: Enter a nickname for the key - submit_value: Add - waiting_heading: Waiting for your security key... - waiting_description: | - Insert the new hardware key into your computer and press the button when - it's blinking. - u2f-unavailable: | - Your browser doesn't look like it supports U2F, the two factor auth - platform supported by Brave. Please use the latest version of Brave, Chrome - or Opera to register your U2F-compatible device, for example a YubiKey. - u2f-error: - bad-request: | - There was an unexpected error in the registration request made by - Brave. Please reload this page and re-attempt registration. - (BAD_REQUEST) - configuration-unsupported: | - Client configuration is not supported. (CONFIGURATION_UNSUPPORTED) - device-ineligible: | - The presented security key is not eligible for registration. This may mean - that the token is already registered. (DEVICE_INELIGIBLE) - other-error: | - There was an unexpected error registering your security key. Re-attempting - registration may resolve this issue. (OTHER_ERROR) - timeout: | - There was an unexpected timeout waiting for your security key to respond to - the registration request. Please re-attempt registration and activate - the security key when it is blinking. (TIMEOUT) - implementation-incomplete: | - Please insert your security key and re-attempt registration. Some - browsers have an incomplete implementation of this - protocol. Please use a current release of Brave, Google Chrome or Opera. - (IMPLEMENTATION_INCOMPLETE) - u2f_registration: - name_default: Anonymous Key - confirm_disable: - header: Remove Security Key? - intro: "Your remaining two-factor authentication method:" - remaining_totp: Authenticator app on your phone - none: None - no_2fa_warning_html: | - Removing this security key will effectively - turn off the two-factor authentication - for your account. - final_confirmation: Are you sure you want to remove this security key? - deny: Do Not Remove - confirm: Remove Security Key diff --git a/config/routes.rb b/config/routes.rb index 1b696efc12..4bb1db1af7 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,5 +1,5 @@ Rails.application.routes.draw do - resources :publishers, only: %i(create update new show destroy) do + resources :publishers, only: %i(create update new show) do collection do # Registrations, eventually we should consider refactoring these routes into something a little more restful scope controller: 'registrations', module: 'publishers' do @@ -38,13 +38,15 @@ patch :disconnect_uphold get :choose_new_channel_type get :two_factor_authentication_removal - get :security, to: 'publishers/security#index' - get :prompt_security, to: 'publishers/security#prompt' - get :settings, to: 'publishers/settings#index' post :request_two_factor_authentication_removal get :confirm_two_factor_authentication_removal get :cancel_two_factor_authentication_removal resources :two_factor_authentications, only: %i(index) + resources :two_factor_registrations, only: %i(index) do + collection do + get :prompt + end + end resources :u2f_registrations, only: %i(new create destroy) resources :u2f_authentications, only: %i(create) resources :totp_registrations, only: %i(new create destroy) diff --git a/test/controllers/publishers_controller_test.rb b/test/controllers/publishers_controller_test.rb index a441c92463..61fc6a7239 100644 --- a/test/controllers/publishers_controller_test.rb +++ b/test/controllers/publishers_controller_test.rb @@ -613,7 +613,7 @@ def request_login_email_uppercase_email(publisher:) sign_in publisher get home_publishers_path - assert_redirected_to prompt_security_publishers_path, "redirects on first visit" + assert_redirected_to prompt_two_factor_registrations_path, "redirects on first visit" follow_redirect! get home_publishers_path diff --git a/test/controllers/totp_registrations_controller_test.rb b/test/controllers/totp_registrations_controller_test.rb index 13c4d0cbb7..7780d869e3 100644 --- a/test/controllers/totp_registrations_controller_test.rb +++ b/test/controllers/totp_registrations_controller_test.rb @@ -47,7 +47,7 @@ class TotpRegistrationsControllerTest < ActionDispatch::IntegrationTest } end - assert_redirected_to security_publishers_path, "redirects to two_factor_registrations" + assert_redirected_to two_factor_registrations_path, "redirects to two_factor_registrations" refute @request.flash[:modal_partial] end @@ -56,7 +56,7 @@ class TotpRegistrationsControllerTest < ActionDispatch::IntegrationTest ROTP::TOTP.any_instance.stubs(:verify_with_drift).returns(true) - get prompt_security_publishers_path + get prompt_two_factor_registrations_path assert_difference("TotpRegistration.count") do post totp_registrations_path, params: { @@ -89,6 +89,6 @@ class TotpRegistrationsControllerTest < ActionDispatch::IntegrationTest } end - assert_redirected_to security_publishers_path, "redirects to two_factor_registrations" + assert_redirected_to two_factor_registrations_path, "redirects to two_factor_registrations" end end diff --git a/test/controllers/two_factor_registrations_controller_test.rb b/test/controllers/two_factor_registrations_controller_test.rb index 637243ac2d..b14b7b40aa 100644 --- a/test/controllers/two_factor_registrations_controller_test.rb +++ b/test/controllers/two_factor_registrations_controller_test.rb @@ -9,7 +9,7 @@ class TwoFactorRegistrationsControllerTest < ActionDispatch::IntegrationTest publisher.update_attribute(:totp_registration, totp_registration) sign_in publisher - get security_publishers_path + get two_factor_registrations_path assert_response :success assert_match "Enabled", response.body @@ -23,7 +23,7 @@ class TwoFactorRegistrationsControllerTest < ActionDispatch::IntegrationTest publisher.u2f_registrations << u2f_registration sign_in publisher - get security_publishers_path + get two_factor_registrations_path assert_response :success assert_match u2f_registration.name, response.body @@ -41,7 +41,7 @@ class TwoFactorRegistrationsControllerTest < ActionDispatch::IntegrationTest publisher.u2f_registrations << additional_u2f_registration sign_in publisher - get security_publishers_path + get two_factor_registrations_path assert_response :success assert_match u2f_registration.name, response.body @@ -55,11 +55,11 @@ class TwoFactorRegistrationsControllerTest < ActionDispatch::IntegrationTest publisher = publishers(:completed) sign_in publisher - get prompt_security_publishers_path + get prompt_two_factor_registrations_path assert_response :success assert_select "a[href=?]", home_publishers_path - assert_select "a[href=?]", security_publishers_path + assert_select "a[href=?]", two_factor_registrations_path assert @request.session[:prompted_for_two_factor_registration_at_signup] end diff --git a/test/controllers/u2f_registrations_controller_test.rb b/test/controllers/u2f_registrations_controller_test.rb index 4d2ec6c3bf..5acbf02660 100644 --- a/test/controllers/u2f_registrations_controller_test.rb +++ b/test/controllers/u2f_registrations_controller_test.rb @@ -53,7 +53,7 @@ def canned_u2f_response } end - assert_redirected_to security_publishers_path, "redirects to two_factor_registrations" + assert_redirected_to two_factor_registrations_path, "redirects to two_factor_registrations" refute @request.flash[:modal_partial] end @@ -68,7 +68,7 @@ def canned_u2f_response ) U2fRegistrationsController.any_instance.stubs(:u2f).returns(mock(:register! => mock_u2f_registration)) - get prompt_security_publishers_path + get prompt_two_factor_registrations_path assert_difference("U2fRegistration.count") do post u2f_registrations_path, params: { @@ -93,7 +93,7 @@ def canned_u2f_response sign_in publisher delete u2f_registration_path(u2f_registration) - assert_redirected_to security_publishers_path, "redirects to two_factor_registrations" + assert_redirected_to two_factor_registrations_path, "redirects to two_factor_registrations" follow_redirect! assert_response :success assert_no_match u2f_registration.name, response.body, "page does not show deleted u2f_registration" diff --git a/test/features/sign_up_test.rb b/test/features/sign_up_test.rb index 7df0b4ea1c..57a3ee5012 100644 --- a/test/features/sign_up_test.rb +++ b/test/features/sign_up_test.rb @@ -23,7 +23,7 @@ class SignUpTest < Capybara::Rails::TestCase fill_in "publisher_name", with: name click_button("Sign Up") - assert_current_path(prompt_security_publishers_path) + assert_current_path(prompt_two_factor_registrations_path) click_link("Skip for now") assert_current_path(home_publishers_path) diff --git a/test/features/two_factor_registrations_test.rb b/test/features/two_factor_registrations_test.rb index 718feae054..7e70b7b109 100644 --- a/test/features/two_factor_registrations_test.rb +++ b/test/features/two_factor_registrations_test.rb @@ -7,7 +7,7 @@ class TwoFactorRegistrationsTest < Capybara::Rails::TestCase publisher = publishers(:verified) sign_in publisher - visit security_publishers_path + visit two_factor_registrations_path assert_content page, "Enabled" refute_content page, "Set Up" # TOTP setup is not available @@ -34,7 +34,7 @@ class TwoFactorRegistrationsTest < Capybara::Rails::TestCase publisher = publishers(:verified) sign_in publisher - visit security_publishers_path + visit two_factor_registrations_path assert_content page, "Enabled" assert_content page, "My U2F Key" # Key is present refute_content page, "No keys have been added" # "No key" warning is not visible diff --git a/yarn.lock b/yarn.lock index ff5a8b79e2..738db5e1e2 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5207,7 +5207,7 @@ is-plain-obj@^1.1.0: resolved "https://registry.yarnpkg.com/is-plain-obj/-/is-plain-obj-1.1.0.tgz#71a50c8429dfca773c92a390a4a03b39fcd51d3e" integrity sha1-caUMhCnfync8kqOQpKA7OfzVHT4= -is-plain-object@^2.0.4: +is-plain-object@^2.0.3, is-plain-object@^2.0.4: version "2.0.4" resolved "https://registry.yarnpkg.com/is-plain-object/-/is-plain-object-2.0.4.tgz#2c163b3fafb1b606d9d17928f05c2a1c38e07677" integrity sha512-h5PpgXkWitc38BBMYawTYMWJHFZJVnBquFE57xFpjB8pJFiF6gZ+bU+WyI/yqXiFR5mdLsgYNaPe8uao6Uv9Og== @@ -9023,12 +9023,15 @@ set-blocking@^2.0.0, set-blocking@~2.0.0: resolved "https://registry.yarnpkg.com/set-blocking/-/set-blocking-2.0.0.tgz#045f9782d011ae9a6803ddd382b24392b3d890f7" integrity sha1-BF+XgtARrppoA93TgrJDkrPYkPc= -set-value@3.0.1, set-value@^2.0.0, set-value@^2.0.1: - version "3.0.1" - resolved "https://registry.yarnpkg.com/set-value/-/set-value-3.0.1.tgz#52c82af7653ba69eb1db92e81f5cdb32739b9e95" - integrity sha512-w6n3GUPYAWQj4ZyHWzD7K2FnFXHx9OTwJYbWg+6nXjG8sCLfs9DGv+KlqglKIIJx+ks7MlFuwFW2RBPb+8V+xg== +set-value@^2.0.0, set-value@^2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/set-value/-/set-value-2.0.1.tgz#a18d40530e6f07de4228c7defe4227af8cad005b" + integrity sha512-JxHc1weCN68wRY0fhCoXpyK55m/XPHafOmK4UWD7m2CI14GMcFypt4w/0+NV5f/ZMby2F6S2wwA7fgynh9gWSw== dependencies: - is-plain-object "^2.0.4" + extend-shallow "^2.0.1" + is-extendable "^0.1.1" + is-plain-object "^2.0.3" + split-string "^3.0.1" setimmediate@^1.0.4, setimmediate@^1.0.5: version "1.0.5" @@ -9278,7 +9281,7 @@ specificity@^0.4.1: resolved "https://registry.yarnpkg.com/specificity/-/specificity-0.4.1.tgz#aab5e645012db08ba182e151165738d00887b019" integrity sha512-1klA3Gi5PD1Wv9Q0wUoOQN1IWAuPu0D1U03ThXTr0cJ20+/iq2tHSDnK7Kk/0LXJ1ztUB2/1Os0wKmfyNgUQfg== -split-string@^3.0.2: +split-string@^3.0.1, split-string@^3.0.2: version "3.1.0" resolved "https://registry.yarnpkg.com/split-string/-/split-string-3.1.0.tgz#7cb09dda3a86585705c64b39a6466038682e8fe2" integrity sha512-NzNVhJDYpwceVVii8/Hu6DKfD2G+NrQHlS/V/qgv763EYudVwEcMQNxd2lh+0VrUByXN/oJkl5grOhYWvQUYiw==