More work on contact validation

This commit is contained in:
Pinga 2024-02-18 15:39:26 +02:00
parent 04c4382836
commit 504bb1b1eb
5 changed files with 66 additions and 7 deletions

View file

@ -414,7 +414,7 @@ class ContactsController extends Controller
$contactPostal = $db->select('SELECT * FROM contact_postalInfo WHERE contact_id = ?',
[ $contact['id'] ]);
return view($response,'admin/contacts/viewContact.twig', [
$responseData = [
'contact' => $contact,
'contactStatus' => $contactStatus,
'contactLinked' => $contactLinked,
@ -422,7 +422,19 @@ class ContactsController extends Controller
'contactPostal' => $contactPostal,
'registrars' => $registrars,
'currentUri' => $uri
]);
];
$verifyPhone = $db->selectValue("SELECT value FROM settings WHERE name = 'verifyPhone'");
$verifyEmail = $db->selectValue("SELECT value FROM settings WHERE name = 'verifyEmail'");
$verifyPostal = $db->selectValue("SELECT value FROM settings WHERE name = 'verifyPostal'");
if ($verifyPhone == 'on' || $verifyEmail == 'on' || $verifyPostal == 'on') {
$contact_validation = $db->selectRow('SELECT validation, validation_stamp, validation_log FROM contact WHERE identifier = ?', [ $args ]);
$responseData['contact_valid'] = $contact_validation['validation'];
$responseData['validation_enabled'] = true;
}
return view($response, 'admin/contacts/viewContact.twig', $responseData);
} else {
// Contact does not exist, redirect to the contacts view
return $response->withHeader('Location', '/contacts')->withStatus(302);
@ -478,7 +490,7 @@ class ContactsController extends Controller
$contactPostal = $db->select('SELECT * FROM contact_postalInfo WHERE contact_id = ?',
[ $contact['id'] ]);
return view($response,'admin/contacts/updateContact.twig', [
$responseData = [
'contact' => $contact,
'contactStatus' => $contactStatus,
'contactAuth' => $contactAuth,
@ -486,7 +498,19 @@ class ContactsController extends Controller
'registrars' => $registrars,
'countries' => $countries,
'currentUri' => $uri
]);
];
$verifyPhone = $db->selectValue("SELECT value FROM settings WHERE name = 'verifyPhone'");
$verifyEmail = $db->selectValue("SELECT value FROM settings WHERE name = 'verifyEmail'");
$verifyPostal = $db->selectValue("SELECT value FROM settings WHERE name = 'verifyPostal'");
if ($verifyPhone == 'on' || $verifyEmail == 'on' || $verifyPostal == 'on') {
$contact_validation = $db->selectRow('SELECT validation, validation_stamp, validation_log FROM contact WHERE identifier = ?', [ $args ]);
$responseData['contact_valid'] = $contact_validation['validation'];
$responseData['validation_enabled'] = true;
}
return view($response, 'admin/contacts/updateContact.twig', $responseData);
} else {
// Contact does not exist, redirect to the contacts view
return $response->withHeader('Location', '/contacts')->withStatus(302);

View file

@ -161,6 +161,22 @@
<!-- You can invert the logic if you prefer the default to be 'Personal' instead of 'Business' -->
</div>
{% if validation_enabled is not null %}
<div class="mb-3">
<button class="btn btn-outline-{% if contact_valid == 0 %}secondary{% elseif contact_valid == 1 %}success{% elseif contact_valid == 2 %}success{% elseif contact_valid == 3 %}info{% endif %} w-100" {% if contact_valid == 1 %}disabled{% elseif contact_valid == 2 %}disabled{% elseif contact_valid == 3 %}disabled{% endif %}>
{% if contact_valid == 0 %}
Trigger Validation
{% elseif contact_valid == 1 %}
Validated by Phone
{% elseif contact_valid == 2 %}
Validated by Email
{% elseif contact_valid == 3 %}
Validated by Postal Mail
{% endif %}
</button>
</div>
{% endif %}
</div>
</div>

View file

@ -26,7 +26,20 @@
<div class="col-12">
<div class="card mb-3">
<div class="card-header">
<h3 class="card-title">{{ __('Contact') }} {{ contact.identifier }}&nbsp;<span class="status status-green">{{ contactStatus.status }}</span>{% if contactLinked is not null %}&nbsp;<span class="status status-info">{{ __('linked') }}</span>{% endif %}</h3>
<h3 class="card-title">{{ __('Contact') }} {{ contact.identifier }}&nbsp;<span class="status status-green">{{ contactStatus.status }}</span>{% if contactLinked is not null %}&nbsp;<span class="status status-info">{{ __('linked') }}</span>{% endif %}
{% if validation_enabled is not null %}
<span class="status {% if contact_valid == 0 %}status-warning{% elseif contact_valid == 1 %}status-success{% elseif contact_valid == 2 %}status-success{% elseif contact_valid == 3 %}status-info{% endif %}" title="{% if contact_valid == 0 %}Pending Validation{% elseif contact_valid == 1 %}Validated by Phone{% elseif contact_valid == 2 %}Validated by Email{% elseif contact_valid == 3 %}Validated by Postal Mail{% endif %}">
{% if contact_valid == 0 %}
Pending Validation
{% elseif contact_valid == 1 %}
Validated by Phone
{% elseif contact_valid == 2 %}
Validated by Email
{% elseif contact_valid == 3 %}
Validated by Postal Mail
{% endif %}
</span>
{% endif %}</h3>
</div>
<div class="card-body">
<div class="datagrid">

View file

@ -248,6 +248,9 @@ CREATE TABLE IF NOT EXISTS `registry`.`contact` (
`disclose_voice` enum('0','1') NOT NULL default '1',
`disclose_fax` enum('0','1') NOT NULL default '1',
`disclose_email` enum('0','1') NOT NULL default '1',
`validation` enum('0','1','2','3','4'),
`validation_stamp` datetime(3) default NULL,
`validation_log` varchar(255) DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `identifier` (`identifier`),
CONSTRAINT `contact_ibfk_1` FOREIGN KEY (`clid`) REFERENCES `registrar` (`id`) ON DELETE RESTRICT,

View file

@ -241,6 +241,9 @@ CREATE TABLE contact (
"disclose_voice" varchar CHECK ("disclose_voice" IN ( '0','1' )) NOT NULL default '1',
"disclose_fax" varchar CHECK ("disclose_fax" IN ( '0','1' )) NOT NULL default '1',
"disclose_email" varchar CHECK ("disclose_email" IN ( '0','1' )) NOT NULL default '1',
"validation" varchar CHECK ("validation" IN ( '0','1','2','3','4' )) default NULL,
"validation_stamp" timestamp(3) without time zone default NULL,
"validation_log" varchar(255) default NULL,
unique ("identifier")
);