mirror of
https://github.com/internetee/registry.git
synced 2025-06-10 14:44:47 +02:00
Merge pull request #2205 from internetee/2184-mail-validation-after-update
added trumail validator after update and implement simple email valid…
This commit is contained in:
commit
3f253ba6cd
4 changed files with 44 additions and 0 deletions
|
@ -12,9 +12,26 @@ module Actions
|
|||
maybe_remove_address
|
||||
maybe_attach_legal_doc
|
||||
validate_ident
|
||||
maybe_change_email
|
||||
commit
|
||||
end
|
||||
|
||||
def maybe_change_email
|
||||
return if Rails.env.test?
|
||||
|
||||
[:regex, :mx].each do |m|
|
||||
r = Actions::SimpleMailValidator.run(email: contact.email, level: m)
|
||||
|
||||
unless r.success
|
||||
contact.add_epp_error('2005', nil, r.errors, I18n.t(:parameter_value_syntax_error))
|
||||
@error = true
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
true
|
||||
end
|
||||
|
||||
def maybe_remove_address
|
||||
return if Contact.address_processing?
|
||||
|
||||
|
|
|
@ -15,9 +15,26 @@ module Actions
|
|||
maybe_update_statuses
|
||||
maybe_update_ident if ident.present?
|
||||
maybe_attach_legal_doc
|
||||
maybe_change_email
|
||||
commit
|
||||
end
|
||||
|
||||
def maybe_change_email
|
||||
return if Rails.env.test?
|
||||
|
||||
[:regex, :mx].each do |m|
|
||||
r = Actions::SimpleMailValidator.run(email: @new_attributes[:email], level: m)
|
||||
|
||||
unless r.success
|
||||
contact.add_epp_error('2005', nil, r.errors, I18n.t(:parameter_value_syntax_error))
|
||||
@error = true
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
true
|
||||
end
|
||||
|
||||
def maybe_remove_address
|
||||
return if Contact.address_processing?
|
||||
|
||||
|
|
9
app/interactions/actions/simple_mail_validator.rb
Normal file
9
app/interactions/actions/simple_mail_validator.rb
Normal file
|
@ -0,0 +1,9 @@
|
|||
module Actions
|
||||
module SimpleMailValidator
|
||||
extend self
|
||||
|
||||
def run(email:, level:)
|
||||
Truemail.validate(email, with: level).result
|
||||
end
|
||||
end
|
||||
end
|
|
@ -371,6 +371,7 @@ en:
|
|||
sim_error: 'SIM application error'
|
||||
internal_error: 'Internal error'
|
||||
client_side_status_editing_error: 'Parameter value policy error. Client-side object status management not supported'
|
||||
parameter_value_syntax_error: 'Parameter value syntax error: '
|
||||
|
||||
# DEPP
|
||||
activemodel:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue