Class: EnableSsoValidator
- Inherits:
-
Object
- Object
- EnableSsoValidator
- Defined in:
- lib/validators/enable_sso_validator.rb
Instance Method Summary collapse
- #error_message ⇒ Object
-
#initialize(opts = {}) ⇒ EnableSsoValidator
constructor
A new instance of EnableSsoValidator.
- #is_2fa_enforced? ⇒ Boolean
- #valid_value?(val) ⇒ Boolean
Constructor Details
#initialize(opts = {}) ⇒ EnableSsoValidator
Returns a new instance of EnableSsoValidator.
4 5 6 |
# File 'lib/validators/enable_sso_validator.rb', line 4 def initialize(opts = {}) @opts = opts end |
Instance Method Details
#error_message ⇒ Object
14 15 16 17 18 19 20 21 22 |
# File 'lib/validators/enable_sso_validator.rb', line 14 def if SiteSetting.discourse_connect_url.blank? return I18n.t("site_settings.errors.discourse_connect_url_is_empty") end if is_2fa_enforced? I18n.t("site_settings.errors.discourse_connect_cannot_be_enabled_if_second_factor_enforced") end end |
#is_2fa_enforced? ⇒ Boolean
24 25 26 |
# File 'lib/validators/enable_sso_validator.rb', line 24 def is_2fa_enforced? SiteSetting.enforce_second_factor? != "no" end |
#valid_value?(val) ⇒ Boolean
8 9 10 11 12 |
# File 'lib/validators/enable_sso_validator.rb', line 8 def valid_value?(val) return true if val == "f" return false if SiteSetting.discourse_connect_url.blank? || is_2fa_enforced? true end |