Project

General

Profile

Feature #35450 » 35450-v3.patch

Go MAEDA, 2022-07-23 02:52

View differences:

app/models/email_address.rb
143 143
  end
144 144

  
145 145
  def validate_email_domain
146
    errors.add(:address, :invalid) unless self.class.valid_domain?(address)
146
    domain = address.partition('@').last
147
    return if self.class.valid_domain?(domain)
148

  
149
    if User.current.logged?
150
      errors.add(:address, :domain_not_allowed, :domain => domain)
151
    else
152
      # Don't display a detailed error message for anonymous users
153
      errors.add(:address, :invalid)
154
    end
147 155
  end
148 156
end
config/locales/en.yml
136 136
        must_contain_lowercase: "must contain lowercase letters (a-z)"
137 137
        must_contain_digits: "must contain digits (0-9)"
138 138
        must_contain_special_chars: "must contain special characters (!, $, %, ...)"
139
        domain_not_allowed: "contains a domain not allowed (%{domain})"
139 140

  
140 141
  actionview_instancetag_blank_option: Please select
141 142

  
test/functional/email_addresses_controller_test.rb
131 131
          }
132 132
        )
133 133
        assert_response :success
134
        assert_select_error 'Email is invalid'
134
        assert_select_error 'Email contains a domain not allowed (black.example)'
135 135
      end
136 136
    end
137 137

  
......
147 147
          }
148 148
        )
149 149
        assert_response :success
150
        assert_select_error 'Email is invalid'
150
        assert_select_error 'Email contains a domain not allowed (example.fr)'
151 151
      end
152 152
    end
153 153
  end
(5-5/5)