* @copyright Since 2007 PrestaShop SA and Contributors * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) */ class RegistrationControllerCore extends FrontController { /** @var bool */ public $ssl = true; /** @var string */ public $php_self = 'registration'; /** @var bool */ public $auth = false; public function checkAccess() { // If the customer is already logged and he got here by 'accident', we will redirect him away if ($this->context->customer->isLogged() && !$this->ajax) { $this->redirect_after = $this->authRedirection ? urlencode($this->authRedirection) : 'my-account'; $this->redirect(); } return parent::checkAccess(); } public function initContent() { $register_form = $this ->makeCustomerForm() ->setGuestAllowed(false) ->fillWith(Tools::getAllValues()); // If registration form was submitted if (Tools::isSubmit('submitCreate')) { $hookResult = array_reduce( Hook::exec('actionSubmitAccountBefore', [], null, true), function ($carry, $item) { return $carry && $item; }, true ); // If no problem occured in the hook, let's get the user redirected if ($hookResult && $register_form->submit() && !$this->ajax) { // First option - redirect the customer to desired URL specified in 'back' parameter // Before that, we need to check if 'back' is legit URL that is on OUR domain, with the right protocol $back = rawurldecode(Tools::getValue('back')); if (Tools::urlBelongsToShop($back)) { return $this->redirectWithNotifications($back); } // Second option - we will redirect him to authRedirection if set if ($this->authRedirection) { return $this->redirectWithNotifications($this->authRedirection); } // Third option - we will redirect him to home URL return $this->redirectWithNotifications(__PS_BASE_URI__); } } $this->context->smarty->assign([ 'register_form' => $register_form->getProxy(), 'hook_create_account_top' => Hook::exec('displayCustomerAccountFormTop'), ]); $this->setTemplate('customer/registration'); parent::initContent(); } public function getBreadcrumbLinks() { $breadcrumb = parent::getBreadcrumbLinks(); $breadcrumb['links'][] = [ 'title' => $this->trans('Create an account', [], 'Shop.Theme.Customeraccount'), 'url' => $this->context->link->getPageLink('registration'), ]; return $breadcrumb; } /** * {@inheritdoc} */ public function getCanonicalURL() { return $this->context->link->getPageLink('registration'); } }