Skip to content

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

DEV: simplify logic (#8249)

Bianca Nenciuff9345fbb0bf
diff --git a/app/assets/javascripts/discourse/routes/preferences-second-factor.js.es6 b/app/assets/javascripts/discourse/routes/preferences-second-factor.js.es6
index 763460bc239..cae63a67073 100644
--- a/app/assets/javascripts/discourse/routes/preferences-second-factor.js.es6
+++ b/app/assets/javascripts/discourse/routes/preferences-second-factor.js.es6
@@ -45,7 +45,7 @@ export default RestrictedUserRoute.extend({
if (
transition.targetName === "preferences.second-factor" ||
!user ||
- (settings.allow_anonymous_posting && user.is_anonymous) ||
+ user.is_anonymous ||
user.second_factor_enabled ||
(settings.enforce_second_factor === "staff" && !user.staff) ||
settings.enforce_second_factor === "no"
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
index 26a1bdf1757..1cd6bd39e50 100644
--- a/app/controllers/application_controller.rb
+++ b/app/controllers/application_controller.rb
@@ -734,7 +734,7 @@ class ApplicationController < ActionController::Base
check_totp = current_user &&
!request.format.json? &&
!is_api? &&
- !(SiteSetting.allow_anonymous_posting && current_user.anonymous?) &&
+ !current_user.anonymous? &&
((SiteSetting.enforce_second_factor == 'staff' && current_user.staff?) ||
SiteSetting.enforce_second_factor == 'all') &&
!current_user.totp_enabled?