从PrestaShop的模块登录Employee



我创建了一个模块,用于在REST中从外部站点登录Employee,如下所示:

带有身份验证令牌和login/pass=>模块使用JWT令牌验证并回答url,如:https://example.com/module/ps_extern_auth/login_jwt?token=FyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJ3d3cuY2FtYS16b25lLmZyIiwiZXhwIjoxNjQzOTA4NjIyLCJlbWFpbCI6ImcubGF0b3JyZUBldmVybGF0cy5jb20iLCJzdWIiOiI0NiJ9.lojt_J1LzeOWYYFCHn5xIuEka-FaEw5OOGk25VXAfNk

当这个JWT令牌被验证时,我给登录员工写下以下代码:

$this->context->employee->remote_addr = ip2long(Tools::getRemoteAddr());
// Update cookie
$cookie = Context::getContext()->cookie;
$cookie->id_employee = $this->context->employee->id;
$cookie->email = $this->context->employee->email;
$cookie->profile = $this->context->employee->id_profile;
$cookie->passwd = $this->context->employee->passwd;
$cookie->remote_addr = $this->context->employee->remote_addr;
$cookie->write();

哪个是从AdminLoginController.php获得的代码如果我var_dump$cookie,我有正确的信息。但是,当员工转到/admin123456/index.php时?controller=AdminProducts他被重定向到登录页面(他没有登录(。

我忘了什么吗?谢谢你的帮助。

PrestaShop 1.6/PHP 7

解决方案:

/*            $cookie = Context::getContext()->cookie; */
$cookie = new Cookie('psAdmin');

最新更新