FIX: second factor cannot be enabled if SSO is enabled (#10880)

* FIX: second factor cannot be enabled if SSO is enabled

If `enable_sso` setting is enabled then admin should not be able to
enable `enforce_second_factor` setting as that will lock users out.

Co-authored-by: Robin Ward <robin.ward@gmail.com>
This commit is contained in:
Arpit Jalan
2020-10-09 22:36:38 +05:30
committed by GitHub
parent d96b35b0f5
commit 4326827a4e
3 changed files with 16 additions and 0 deletions

View File

@ -173,6 +173,9 @@ module SiteSettings::Validations
end
def validate_enforce_second_factor(new_val)
if SiteSetting.enable_sso?
return validate_error :second_factor_cannot_be_enforced_with_sso_enabled
end
if new_val == "all" && Discourse.enabled_auth_providers.count > 0
auth_provider_names = Discourse.enabled_auth_providers.map(&:name).join(", ")
return validate_error(:second_factor_cannot_enforce_with_socials, auth_provider_names: auth_provider_names)