diff options
author | Dave Arter <davea@mysociety.org> | 2020-01-20 15:47:43 +0000 |
---|---|---|
committer | Dave Arter <davea@mysociety.org> | 2020-01-20 19:30:51 +0000 |
commit | c0fbe0a55bb2c24fb7e07b0972a3306c00552d1c (patch) | |
tree | dfd494836cf616d1fc70561a7c1f33bebe5fca19 | |
parent | d87a4661bc49d1918cd7fcd617c7f2c1f9474263 (diff) |
Skip admin contact email validation check if address hasn’t changed
Some contacts (e.g. TfL) don’t have a valid email address but aren’t Open311
categories - the email destination is managed via the borough_email_addresses
feature. This prevents any changes to the contact being made via the admin
due to the email validation error message.
This commit updates the logic to only check that the email address is valid
if it’s been changed from the existing value (which may be blank if a it’s a
new contact).
Fixes https://github.com/mysociety/fixmystreet-freshdesk/issues/108
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Admin/Bodies.pm | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Admin/Bodies.pm b/perllib/FixMyStreet/App/Controller/Admin/Bodies.pm index 3b7739966..18bcbbc5f 100644 --- a/perllib/FixMyStreet/App/Controller/Admin/Bodies.pm +++ b/perllib/FixMyStreet/App/Controller/Admin/Bodies.pm @@ -248,7 +248,8 @@ sub update_contact : Private { my $email = $c->get_param('email'); $email =~ s/\s+//g; my $send_method = $c->get_param('send_method') || $contact->body->send_method || ""; - unless ( $send_method eq 'Open311' ) { + my $email_unchanged = $contact->email && $email && $contact->email eq $email; + unless ( $send_method eq 'Open311' || $email_unchanged ) { $errors{email} = _('Please enter a valid email') unless is_valid_email_list($email) || $email eq 'REFUSED'; } |