FIX: Error message when setting enforce 2fa with social logins (#10479)

This commit is contained in:
Mark VanLandingham
2020-08-19 13:16:31 -05:00
committed by GitHub
parent 298ed5d021
commit a3c0d4a8b5
3 changed files with 19 additions and 2 deletions

View File

@ -156,6 +156,10 @@ module SiteSettings::Validations
end
def validate_enforce_second_factor(new_val)
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)
end
return if SiteSetting.enable_local_logins
return if new_val == "no"
validate_error :second_factor_cannot_be_enforced_with_disabled_local_login