Skip to content

Commit

Permalink
Use email address class validation
Browse files Browse the repository at this point in the history
Originally there was a validation function for email addresses.  The
customer data changes switched to a method on the cd_email class for
processing the email address input.  These two pages do not use the
customer data input or processing.  So they continued to use the old
way.

This will allow us to deprecate the functions/validations.php file.
  • Loading branch information
ecartz committed Dec 4, 2020
1 parent 4bef409 commit da2f654
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
8 changes: 6 additions & 2 deletions contact_us.php
Expand Up @@ -21,12 +21,16 @@
$email_address = tep_db_prepare_input($_POST['email']);
$enquiry = tep_db_prepare_input($_POST['enquiry']);

if (!tep_validate_email($email_address)) {
$email_class = $customer_data->has('email_address')
? get_class($customer_data->get_module('email_address'))
: 'cd_email_address';

if (!$email_class::validate($email_address)) {
tep_block_form_processing();

$messageStack->add('contact', ENTRY_EMAIL_ADDRESS_CHECK_ERROR);
}

$OSCOM_Hooks->call('siteWide', 'injectFormVerify');

$actionRecorder = new actionRecorder('ar_contact_us', ($_SESSION['customer_id'] ?? null), $name);
Expand Down
9 changes: 5 additions & 4 deletions password_reset.php
Expand Up @@ -27,7 +27,9 @@
$email_address = tep_db_prepare_input($_GET['account']);
$password_key = tep_db_prepare_input($_GET['key']);

if ( (strlen($email_address) < ENTRY_EMAIL_ADDRESS_MIN_LENGTH) || !tep_validate_email($email_address) ) {
$email_class = get_class($customer_data->get_module('email_address'));

if ( (strlen($email_address) < ENTRY_EMAIL_ADDRESS_MIN_LENGTH) || !$email_class::validate($email_address) ) {
$error = true;

$messageStack->add_session('password_forgotten', TEXT_NO_EMAIL_ADDRESS_FOUND);
Expand Down Expand Up @@ -61,7 +63,6 @@

if (tep_validate_form_action_is('process')) {
$customer_details = $customer_data->process($page_fields);
$OSCOM_Hooks->call('siteWide', 'injectFormVerify');

if (tep_form_processing_is_valid()) {
$customer_data->update(['password' => $customer_data->get('password', $customer_details)], ['id' => (int)$customer_data->get('id', $check_customer)]);
Expand All @@ -70,9 +71,9 @@

$messageStack->add_session('login', SUCCESS_PASSWORD_RESET, 'success');

tep_redirect(tep_href_link('login.php', '', 'SSL'));
tep_redirect(tep_href_link('login.php'));
}
}

require $oscTemplate->map_to_template(__FILE__, 'page');
require 'includes/application_bottom.php';

0 comments on commit da2f654

Please sign in to comment.