Zen Follower
- Join Date:
- Jun 2012
- Posts:
- 481
- Plugin Contributions:
- 0
Request for new notifier in login process
It would be useful to implement a new notifier in includes/modules/pages/login/header_php.php after email, banned, and password validation for additional customer login checks that interrupt the login process to display messages to the customer. The notifier, if implemented, avoids custom code in the core file.
In my case, certain customers are "members" who get certain benefits, including discounts, free downloads, and potentially access to special product categories or access to other stores with the same login credentials. But membership may lapse and I want to display a message via $messageStack during login, stating membership has lapsed (if true), but they can continue without the benefits by clicking login. Other notifiers in the header are not appropriate because information is not yet available, bring up inappropriate messages if login is not authorized, or won't display messages because of redirects.
Another reason for a new notifier (for us) is to provide a means to display the "Privacy Notice must be accepted" message to only customers in the EU who have not already checked the accept box in the login form.
Changes to the header must be made to implement a new notifier to avoid conflict with the 3rd party logon notifier. In addition, movement of the check_country_query from the login success path to before the new notifier would be nice so the observer can use entry_country_id. This latter change is desirable, but not necessary, as the extra query could be run in the observer.
Suggested code follows, picking up at the 3rd party login notifier (changes in red):
$zco_notifier->notify('NOTIFY_PROCESS_3RD_PARTY_LOGINS', $email_address, $password, $loginAuthorized);
if (!$loginAuthorized) {
$error = true;
$messageStack->add('login', TEXT_LOGIN_ERROR);
}
// BOF -- change to move query before notifier so observer has access to entry_country_id
$check_country_query = "SELECT entry_country_id, entry_zone_id
FROM " . TABLE_ADDRESS_BOOK . "
WHERE customers_id = :customersID
AND address_book_id = :addressBookID";
$check_country_query = $db->bindVars($check_country_query, ':customersID', $check_customer->fields['customers_id'], 'integer');
$check_country_query = $db->bindVars($check_country_query, ':addressBookID',
$check_customer->fields['customers_default_address_id'], 'integer');
$check_country = $db->Execute($check_country_query);
// EOF -- change to move query before notifier so observer has access to entry_country_id
// BOF -- change to add notifier for additional login checks
$zco_notifier->notify('NOTIFY_PROCESS_ADDITIONAL_LOGIN_CHECKS', $error, $loginAuthorized);
if (!$loginAuthorized) {
$error = true;
// EOF -- change to add notifier for additional login checks
} else {
The code continues down the login success path. Passing $error to the observer allows the observer code to be bypassed if there are problems with the email address, customer is banned or a problem with the password. The observer sets $loginAuthorized to false and sets up $message Stack as needed.