php - 尝试进入我的帐户部分时出现重定向 ERR_TOO_MANY_REDIRECTS prestashop 的问题
问题描述
在我的网站lonnatu.com 上,如果您尝试登录,则会出现找不到重定向问题。此 URL https://lonnatu.com/my-account重定向到此https://lonnatu.com/inicio-sesion?back=my-account以便能够登录或创建帐户,但登录时您应该重定向到这个https://lonnatu.com/my-account并且不再返回到另一个。
我已经知道它可以是一个名为的文件,AuthController.php
但我不知道我必须更改哪个部分。
class AuthControllerCore extends FrontController
{
public $ssl = true;
public $php_self = 'authentication';
public $auth = false;
public function checkAccess()
{
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()
{
$should_redirect = false;
if (Tools::isSubmit('submitCreate') || Tools::isSubmit('create_account')) {
$register_form = $this
->makeCustomerForm()
->setGuestAllowed(false)
->fillWith(Tools::getAllValues())
;
if (Tools::isSubmit('submitCreate')) {
$hookResult = array_reduce(
Hook::exec('actionSubmitAccountBefore', array(), null, true),
function ($carry, $item) {
return $carry && $item;
},
true
);
if ($hookResult && $register_form->submit()) {
$should_redirect = true;
}
}
$this->context->smarty->assign([
'register_form' => $register_form->getProxy(),
'hook_create_account_top' => Hook::exec('displayCustomerAccountFormTop'),
]);
$this->setTemplate('customer/registration');
} else {
$login_form = $this->makeLoginForm()->fillWith(
Tools::getAllValues()
);
if (Tools::isSubmit('submitLogin')) {
if ($login_form->submit()) {
$should_redirect = true;
}
}
$this->context->smarty->assign([
'login_form' => $login_form->getProxy(),
]);
$this->setTemplate('customer/authentication');
}
parent::initContent();
if ($should_redirect && !$this->ajax) {
$back = urldecode(Tools::getValue('back'));
if (Tools::urlBelongsToShop($back)) {
// Checks to see if "back" is a fully qualified
// URL that is on OUR domain, with the right protocol
return $this->redirectWithNotifications($back);
}
// Well we're not redirecting to a URL,
// so...
if ($this->authRedirection) {
// We may need to go there if defined
return $this->redirectWithNotifications($this->authRedirection);
}
// go home
return $this->redirectWithNotifications(__PS_BASE_URI__);
}
}
}
解决方案
推荐阅读
- java - InetAddress 不断变化,我没有得到我期望的地址
- c# - 如何找到从 xml 到 C# 对象的反序列化错误的确切原因?
- python - 在完全匹配python正则表达式之前提取带逗号的数字?
- kubernetes - Kubernetes 集群未删除
- php - 如何构造一个依赖于要加载的会话的对象
- arrays - 从 bytearray 转换为 hexa Kotlin
- android - Poco 库 - 通过 CMakeList.txt 在 Android 中包含共享库
- azure - 使用 Azure 磁盘的 Azure Kubernetes 服务中的持久存储问题
- python - 如何在另一列的基础上填充该列第一行的NA值
- python - chr 函数不接受更高的答案有什么具体原因吗?