mirror of
https://github.com/getnamingo/registry.git
synced 2025-07-21 10:06:05 +02:00
Even more work on contact validation
This commit is contained in:
parent
159228e303
commit
19a4dc4048
3 changed files with 33 additions and 7 deletions
|
@ -7,6 +7,10 @@ use Psr\Http\Message\ResponseInterface as Response;
|
||||||
use Psr\Http\Message\ServerRequestInterface as Request;
|
use Psr\Http\Message\ServerRequestInterface as Request;
|
||||||
use Psr\Container\ContainerInterface;
|
use Psr\Container\ContainerInterface;
|
||||||
use League\ISO3166\ISO3166;
|
use League\ISO3166\ISO3166;
|
||||||
|
use Egulias\EmailValidator\EmailValidator;
|
||||||
|
use Egulias\EmailValidator\Validation\DNSCheckValidation;
|
||||||
|
use Egulias\EmailValidator\Validation\MultipleValidationWithAnd;
|
||||||
|
use Egulias\EmailValidator\Validation\RFCValidation;
|
||||||
|
|
||||||
class ContactsController extends Controller
|
class ContactsController extends Controller
|
||||||
{
|
{
|
||||||
|
@ -585,6 +589,27 @@ class ContactsController extends Controller
|
||||||
$responseData['verifyPostal'] = $verifyPostal;
|
$responseData['verifyPostal'] = $verifyPostal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($verifyPhone == 'on') {
|
||||||
|
$phoneUtil = \libphonenumber\PhoneNumberUtil::getInstance();
|
||||||
|
try {
|
||||||
|
$numberProto = $phoneUtil->parse($contact['voice'], $contactPostal[0]['cc']);
|
||||||
|
$isValid = $phoneUtil->isValidNumber($numberProto);
|
||||||
|
$responseData['phoneDetails'] = $isValid;
|
||||||
|
} catch (\libphonenumber\NumberParseException $e) {
|
||||||
|
$responseData['phoneDetails'] = $e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($verifyEmail == 'on') {
|
||||||
|
$validator = new EmailValidator();
|
||||||
|
$multipleValidations = new MultipleValidationWithAnd([
|
||||||
|
new RFCValidation(),
|
||||||
|
new DNSCheckValidation()
|
||||||
|
]);
|
||||||
|
$isValid = $validator->isValid($contact['email'], $multipleValidations);
|
||||||
|
$responseData['emailDetails'] = $isValid;
|
||||||
|
}
|
||||||
|
|
||||||
return view($response, 'admin/contacts/validateContact.twig', $responseData);
|
return view($response, 'admin/contacts/validateContact.twig', $responseData);
|
||||||
} else {
|
} else {
|
||||||
// Contact does not exist, redirect to the contacts view
|
// Contact does not exist, redirect to the contacts view
|
||||||
|
|
|
@ -43,7 +43,8 @@
|
||||||
"ramsey/uuid": "^4.7",
|
"ramsey/uuid": "^4.7",
|
||||||
"selective/xmldsig": "^3.1",
|
"selective/xmldsig": "^3.1",
|
||||||
"adyen/php-api-library": "^17.1",
|
"adyen/php-api-library": "^17.1",
|
||||||
"giggsey/libphonenumber-for-php-lite": "^8.13"
|
"giggsey/libphonenumber-for-php-lite": "^8.13",
|
||||||
|
"egulias/email-validator": "^4.0"
|
||||||
},
|
},
|
||||||
"autoload": {
|
"autoload": {
|
||||||
"psr-4": {
|
"psr-4": {
|
||||||
|
|
|
@ -51,27 +51,27 @@
|
||||||
{% if verifyPhone == 'on' %}
|
{% if verifyPhone == 'on' %}
|
||||||
{# The content you want to echo if verifyPhone is 'on' #}
|
{# The content you want to echo if verifyPhone is 'on' #}
|
||||||
<h4>
|
<h4>
|
||||||
Phone verification is enabled.
|
Phone Validation
|
||||||
</h4>
|
</h4>
|
||||||
<div>
|
<div>
|
||||||
<pre><code>Validation TBD.</code></pre>
|
<pre><code>{{ phoneDetails ? 'Number valid' : 'Number invalid' }}</code></pre>
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% if verifyEmail == 'on' %}
|
{% if verifyEmail == 'on' %}
|
||||||
{# The content you want to echo if verifyEmail is 'on' #}
|
{# The content you want to echo if verifyEmail is 'on' #}
|
||||||
<h4>
|
<h4>
|
||||||
Email verification is enabled.
|
Email Validation
|
||||||
</h4>
|
</h4>
|
||||||
<div>
|
<div>
|
||||||
<pre><code>Validation TBD.</code></pre>
|
<pre><code>{{ emailDetails == 1 ? 'Email valid' : 'Email invalid' }}</code></pre>
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% if verifyPostal == 'on' %}
|
{% if verifyPostal == 'on' %}
|
||||||
{# The content you want to echo if verifyPostal is 'on' #}
|
{# The content you want to echo if verifyPostal is 'on' #}
|
||||||
<h4>
|
<h4>
|
||||||
Postal Mail verification is enabled.
|
Postal Mail Validation
|
||||||
</h4>
|
</h4>
|
||||||
<div>
|
<div>
|
||||||
<pre><code>Validation TBD.</code></pre>
|
<pre><code>Validation TBD.</code></pre>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue