GuimDotcom Posted February 4, 2022 Share Posted February 4, 2022 (edited) I have created a module to sign in Employee from an external site in REST like this: A JSON Post with Authentication token and login/pass => module validate and answer an url with a JWT token like: https://example.com/module/ps_extern_auth/login_jwt?token=FyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJ3d3cuY2FtYS16b25lLmZyIiwiZXhwIjoxNjQzOTA4NjIyLCJlbWFpbCI6ImcubGF0b3JyZUBldmVybGF0cy5jb20iLCJzdWIiOiI0NiJ9.lojt_J1LzeOWYYFCHn5xIuEka-FaEw5OOGk25VXAfNk When this JWT token is validated, I write this code to login employee: $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(); Which is the code get from AdminLoginController.php If I var_dump $cookie, I have correct informations. But then, when the employee go to /admin123456/index.php?controller=AdminProducts He is redirected to login page (He's not logged in). Do I forget something? Thanks for your help. PrestaShop 1.6 / PHP 7 Edited February 4, 2022 by GuimDotcom Solved (see edit history) Link to comment Share on other sites More sharing options...
GuimDotcom Posted February 4, 2022 Author Share Posted February 4, 2022 I found the solution: // $cookie = Context::getContext()->cookie; $cookie = new Cookie('psAdmin'); Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now