FEATURE: 'reply by email address' validator

Prevent infinite email loophole when the 'reply_by_email_address' site setting is the same as the 'notification_email'.
This commit is contained in:
Régis Hanol
2015-02-06 12:08:37 +01:00
parent 4db3caec7c
commit f7d2fc0524
6 changed files with 72 additions and 16 deletions

View File

@ -72,18 +72,22 @@ module SiteSettingExtension
self.defaults[name] = default
categories[name] = opts[:category] || :uncategorized
current_value = current.has_key?(name) ? current[name] : default
if opts[:enum]
enum = opts[:enum]
enums[name] = enum.is_a?(String) ? enum.constantize : enum
end
if opts[:choices]
choices.has_key?(name) ?
choices[name].concat(opts[:choices]) :
choices[name] = opts[:choices]
end
if opts[:type] == 'list'
lists << name
end
if opts[:hidden]
hidden_settings << name
end
@ -105,8 +109,11 @@ module SiteSettingExtension
previews[name] = opts[:preview]
end
if validator_type = validator_for(opts[:type] || get_data_type(name, defaults[name]))
validators[name] = {class: validator_type, opts: opts}
opts[:validator] = opts[:validator].try(:constantize)
type = opts[:type] || get_data_type(name, defaults[name])
if validator_type = opts[:validator] || validator_for(type)
validators[name] = { class: validator_type, opts: opts }
end
current[name] = current_value