Skip to content

A platform for community discussion. Free, open, simple.

DEV: Allow enabling safe-mode even when missing required fields (#29310)

Ted Johanssonb1321b985a8c
diff --git a/app/assets/javascripts/discourse/app/services/restricted-routing.js b/app/assets/javascripts/discourse/app/services/restricted-routing.js
index b8e1e05c037..42bece7b434 100644
--- a/app/assets/javascripts/discourse/app/services/restricted-routing.js
+++ b/app/assets/javascripts/discourse/app/services/restricted-routing.js
@@ -9,7 +9,7 @@ export default class RestrictedRouting extends Service {
}
isAllowedRoute(path) {
- const alwaysAllowed = ["faq", "about", "tos", "privacy"];
+ const alwaysAllowed = ["faq", "about", "tos", "privacy", "safe-mode"];
if (alwaysAllowed.includes(path)) {
return true;
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
index 94330d14d07..5982404e6e4 100644
--- a/app/controllers/application_controller.rb
+++ b/app/controllers/application_controller.rb
@@ -928,7 +928,7 @@ class ApplicationController < ActionController::Base
redirect_path = path("/u/#{current_user.encoded_username}/preferences/profile")
second_factor_path = path("/u/#{current_user.encoded_username}/preferences/second-factor")
- allowed_paths = [redirect_path, second_factor_path, path("/admin")]
+ allowed_paths = [redirect_path, second_factor_path, path("/admin"), path("/safe-mode")]
if allowed_paths.none? { |p| request.fullpath.start_with?(p) }
rate_limiter = RateLimiter.new(current_user, "redirect_to_required_fields_log", 1, 24.hours)
diff --git a/spec/system/user_page/user_preferences_profile_spec.rb b/spec/system/user_page/user_preferences_profile_spec.rb
index d109a271540..de9f73ceaee 100644
--- a/spec/system/user_page/user_preferences_profile_spec.rb
+++ b/spec/system/user_page/user_preferences_profile_spec.rb
@@ -77,5 +77,15 @@ describe "User preferences | Profile", type: :system do
expect(page).to have_current_path("/")
end
+
+ it "allows enabling safe-mode" do
+ visit("/safe-mode")
+
+ expect(page).to have_current_path("/safe-mode")
+
+ page.find("#btn-enter-safe-mode").click
+
+ expect(page).to have_current_path("/u/#{user.username}/preferences/profile")
+ end
end
end