Merge remote-tracking branch 'origin/ticket/r15670-email'
This commit is contained in:
commit
dbbb5a7817
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/*
|
||||
* 2007-2011 PrestaShop
|
||||
* 2007-2011 PrestaShop
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
@ -40,18 +40,20 @@ class IdentityControllerCore extends FrontController
|
||||
|
||||
if (sizeof($_POST))
|
||||
{
|
||||
$exclusion = array('secure_key',
|
||||
'old_passwd',
|
||||
'passwd',
|
||||
'active',
|
||||
'date_add',
|
||||
'date_upd',
|
||||
'last_passwd_gen',
|
||||
'newsletter_date_add',
|
||||
'id_default_group',
|
||||
'ip_registration_newsletter',
|
||||
'note',
|
||||
'is_guest');
|
||||
$exclusion = array(
|
||||
'secure_key',
|
||||
'old_passwd',
|
||||
'passwd',
|
||||
'active',
|
||||
'date_add',
|
||||
'date_upd',
|
||||
'last_passwd_gen',
|
||||
'newsletter_date_add',
|
||||
'id_default_group',
|
||||
'ip_registration_newsletter',
|
||||
'note',
|
||||
'is_guest'
|
||||
);
|
||||
$fields = $customer->getFields();
|
||||
foreach ($fields AS $key => $value)
|
||||
if (!in_array($key, $exclusion))
|
||||
|
@ -1,12 +1,14 @@
|
||||
<?php
|
||||
class AuthController extends AuthControllerCore {
|
||||
public function preProcess() {
|
||||
class AuthController extends AuthControllerCore
|
||||
{
|
||||
public function preProcess()
|
||||
{
|
||||
// We can't run parent::preProcess() here since it would run the authentication process
|
||||
|
||||
if(!isset($this->php_self)) {
|
||||
if (!isset($this->php_self)) {
|
||||
$this->php_self = strtolower(basename($_SERVER['PHP_SELF']));
|
||||
}
|
||||
if($this->php_self == '404.php') {
|
||||
if ($this->php_self == '404.php') {
|
||||
$page_name = 'page-404';
|
||||
} else {
|
||||
if(preg_match('#^'.__PS_BASE_URI__.'modules/([a-zA-Z0-9_-]+?)/([^?]*)(\?(.*))?$#', strtolower($_SERVER['REQUEST_URI']), $m)) {
|
||||
@ -79,42 +81,47 @@ class AuthController extends AuthControllerCore {
|
||||
|
||||
Module::hookExec('preprocess');
|
||||
|
||||
if(self::$cookie->isLogged() && !Tools::isSubmit('ajax')) {
|
||||
if (self::$cookie->isLogged() && !Tools::isSubmit('ajax')) {
|
||||
Tools::redirect('/');
|
||||
}
|
||||
|
||||
if(Tools::getValue('create_account')) {
|
||||
if (Tools::getValue('create_account')) {
|
||||
$create_account = 1;
|
||||
self::$smarty->assign('email_create', 1);
|
||||
}
|
||||
|
||||
if(Tools::isSubmit('SubmitCreate')) {
|
||||
if (Tools::isSubmit('SubmitCreate')) {
|
||||
$create_account = 1;
|
||||
self::$smarty->assign('email_create', Tools::safeOutput($email));
|
||||
}
|
||||
|
||||
if(Tools::isSubmit('submitAccount') || Tools::isSubmit('submitGuestAccount')) {
|
||||
if (Tools::isSubmit('submitAccount') || Tools::isSubmit('submitGuestAccount')) {
|
||||
$create_account = 1;
|
||||
if(Tools::isSubmit('submitAccount'))
|
||||
self::$smarty->assign('email_create', 1);
|
||||
/* New Guest customer */
|
||||
if(!Tools::getValue('is_new_customer', 1) && !Configuration::get('PS_GUEST_CHECKOUT_ENABLED')) {
|
||||
if(Tools::isSubmit('submitAccount')) {
|
||||
self::$smarty->assign('email_create', 1);
|
||||
}
|
||||
|
||||
/* New Guest customer */
|
||||
if (!Tools::getValue('is_new_customer', 1) && !Configuration::get('PS_GUEST_CHECKOUT_ENABLED')) {
|
||||
$this->errors[] = Tools::displayError('You cannot create a guest account.');
|
||||
}
|
||||
if(!Tools::getValue('is_new_customer', 1)) {
|
||||
|
||||
if (!Tools::getValue('is_new_customer', 1)) {
|
||||
$_POST['passwd'] = md5(time()._COOKIE_KEY_);
|
||||
}
|
||||
if(isset($_POST['guest_email']) && $_POST['guest_email']) {
|
||||
$_POST['email'] = $_POST['guest_email'];
|
||||
|
||||
$email = Tools::getValue('email');
|
||||
if (Tools::getValue('guest_email') !== false) {
|
||||
$email = Tools::getValue('guest_email');
|
||||
}
|
||||
$email = strtolower(trim($email));
|
||||
|
||||
$_POST['email'] = trim($_POST['email']);
|
||||
/** @Override Antadis - mail fixing */
|
||||
$_POST['email'] = str_replace(array('@hotmil.','@htmail.','@hotmal.','@hotml.','@hotmai.'),'@hotmail.',$_POST['email']);
|
||||
$_POST['email'] = str_replace(array('@gmal.','@gail.','@gml.','@gmai.','@gmil.'),'@gmail.',$_POST['email']);
|
||||
$_POST['email'] = str_replace('@gmailcom','@gmail.com',$_POST['email']);
|
||||
$_POST['email'] = str_replace('@hotmailcom','@hotmail.com',$_POST['email']);
|
||||
$_POST['email'] = str_replace('@hotmailfr','@hotmail.fr',$_POST['email']);
|
||||
$email = str_replace(array('@hotmil.','@htmail.','@hotmal.','@hotml.','@hotmai.'),'@hotmail.', $email);
|
||||
$email = str_replace(array('@gmal.','@gail.','@gml.','@gmai.','@gmil.'),'@gmail.', $email);
|
||||
$email = str_replace('@gmailcom','@gmail.com', $email);
|
||||
$email = str_replace('@hotmailcom','@hotmail.com', $email);
|
||||
$email = str_replace('@hotmailfr','@hotmail.fr', $email);
|
||||
/** @End Override Antadis - mail fixing */
|
||||
|
||||
/* Preparing customer */
|
||||
@ -132,8 +139,8 @@ class AuthController extends AuthControllerCore {
|
||||
$_POST['lastname'] = $lastnameAddress;
|
||||
$_POST['firstname'] = $firstnameAddress;
|
||||
|
||||
if(!sizeof($this->errors)) {
|
||||
if(Customer::customerExists(Tools::getValue('email'))) {
|
||||
if (!sizeof($this->errors)) {
|
||||
if(Customer::customerExists($email)) {
|
||||
$this->errors[] = Tools::displayError('An account is already registered with this e-mail, please fill in the password or request a new one.');
|
||||
}
|
||||
if(Tools::isSubmit('newsletter')) {
|
||||
@ -143,15 +150,15 @@ class AuthController extends AuthControllerCore {
|
||||
|
||||
$customer->birthday = (empty($_POST['years'])? '': (int)($_POST['years']).'-'.(int)($_POST['months']).'-'.(int)($_POST['days']));
|
||||
|
||||
if(!sizeof($this->errors)) {
|
||||
if (!sizeof($this->errors)) {
|
||||
$customer->active = 1;
|
||||
/* New Guest customer */
|
||||
if(Tools::isSubmit('is_new_customer')) {
|
||||
if (Tools::isSubmit('is_new_customer')) {
|
||||
$customer->is_guest = !Tools::getValue('is_new_customer', 1);
|
||||
} else {
|
||||
$customer->is_guest = 0;
|
||||
}
|
||||
if(!$customer->add()) {
|
||||
if (!$customer->add()) {
|
||||
$this->errors[] = Tools::displayError('An error occurred while creating your account.');
|
||||
} else {
|
||||
if(!$customer->is_guest) {
|
||||
@ -188,7 +195,7 @@ class AuthController extends AuthControllerCore {
|
||||
'_POST' => $_POST,
|
||||
'newCustomer' => $customer
|
||||
));
|
||||
if(Tools::isSubmit('ajax')) {
|
||||
if (Tools::isSubmit('ajax')) {
|
||||
$return = array(
|
||||
'hasError' => !empty($this->errors),
|
||||
'errors' => $this->errors,
|
||||
@ -200,7 +207,7 @@ class AuthController extends AuthControllerCore {
|
||||
);
|
||||
die(Tools::jsonEncode($return));
|
||||
}
|
||||
if($back = Tools::getValue('back')) {
|
||||
if ($back = Tools::getValue('back')) {
|
||||
if($back == '/') {
|
||||
$back = '/index.php?validation=1';
|
||||
Tools::redirect($back);
|
||||
@ -211,7 +218,8 @@ class AuthController extends AuthControllerCore {
|
||||
}
|
||||
}
|
||||
}
|
||||
if(sizeof($this->errors)) {
|
||||
|
||||
if (sizeof($this->errors)) {
|
||||
if(!Tools::getValue('is_new_customer')) {
|
||||
unset($_POST['passwd']);
|
||||
}
|
||||
@ -227,7 +235,7 @@ class AuthController extends AuthControllerCore {
|
||||
}
|
||||
}
|
||||
|
||||
if(Tools::isSubmit('SubmitLogin')) {
|
||||
if (Tools::isSubmit('SubmitLogin')) {
|
||||
Module::hookExec('beforeAuthentication');
|
||||
$passwd = trim(Tools::getValue('passwd'));
|
||||
$email = trim(Tools::getValue('email'));
|
||||
@ -244,7 +252,7 @@ class AuthController extends AuthControllerCore {
|
||||
} else {
|
||||
$customer = new Customer();
|
||||
$authentication = $customer->getByEmail(trim($email), trim($passwd));
|
||||
if(!$authentication || !$customer->id) {
|
||||
if (!$authentication || !$customer->id) {
|
||||
/* Handle brute force attacks */
|
||||
sleep(1);
|
||||
$this->errors[] = Tools::displayError('Authentication failed');
|
||||
@ -288,7 +296,7 @@ class AuthController extends AuthControllerCore {
|
||||
}
|
||||
}
|
||||
}
|
||||
if(Tools::isSubmit('ajax')) {
|
||||
if (Tools::isSubmit('ajax')) {
|
||||
$return = array(
|
||||
'hasError' => !empty($this->errors),
|
||||
'errors' => $this->errors,
|
||||
@ -298,7 +306,7 @@ class AuthController extends AuthControllerCore {
|
||||
}
|
||||
}
|
||||
|
||||
if(isset($create_account)) {
|
||||
if (isset($create_account)) {
|
||||
/* Call a hook to display more information on form */
|
||||
self::$smarty->assign(array(
|
||||
'HOOK_CREATE_ACCOUNT_FORM' => Module::hookExec('createAccountForm'),
|
||||
@ -332,14 +340,16 @@ class AuthController extends AuthControllerCore {
|
||||
self::$smarty->assign('newsletter', (int)Module::getInstanceByName('blocknewsletter')->active);
|
||||
}
|
||||
|
||||
public function displayContent() {
|
||||
public function displayContent()
|
||||
{
|
||||
Tools::safePostVars();
|
||||
self::$smarty->assign('errors', $this->errors);
|
||||
self::$smarty->assign('HOOK_CREATE_ACCOUNT_FORM_BOTTOM', Module::hookExec('createAccountFormBottom', array()));
|
||||
self::$smarty->display(_PS_THEME_DIR_.'authentication.tpl');
|
||||
}
|
||||
|
||||
public function setMedia() {
|
||||
public function setMedia()
|
||||
{
|
||||
parent::setMedia();
|
||||
|
||||
global $css_files;
|
||||
|
@ -1,11 +1,27 @@
|
||||
<?php
|
||||
class IdentityController extends IdentityControllerCore {
|
||||
public function preProcess() {
|
||||
class IdentityController extends IdentityControllerCore
|
||||
{
|
||||
public function preProcess()
|
||||
{
|
||||
self::$smarty->assign(array('HOOK_PROFILE_EDIT' => Module::hookExec('profileEdit')));
|
||||
|
||||
if (Tools::isSubmit('submitIdentity')) {
|
||||
$customer = new Customer((int)(self::$cookie->id_customer));
|
||||
if (isset($_POST['email'])) {
|
||||
$_POST['email'] = strtolower(trim($_POST['email']));
|
||||
if ($_POST['email'] != $customer->email) {
|
||||
if (Customer::customerExists($_POST['email'])) {
|
||||
$this->errors[] = Tools::displayError('An account is already registered with this e-mail');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
parent::preProcess();
|
||||
}
|
||||
|
||||
public function setMedia() {
|
||||
public function setMedia()
|
||||
{
|
||||
parent::setMedia();
|
||||
|
||||
global $css_files;
|
||||
|
Loading…
Reference in New Issue
Block a user