[email protected] Posted May 3, 2013 Share Posted May 3, 2013 I'm writing a module for Prestashop 1.5, and have a table with links to some orders, in the backend. I'm trying to generate a link to an order item, but when I click the link, I get a screen telling me: Invalid security token In my template I have the following snippet: <a href="{$script_name}?controller=adminorders&id_order={$p.id_order}&vieworder&token={$token}">{$p.id_order}</a> When I click the I understand the risks.. warning, the page displays fine, and loads the order appropriately. I just want to get rid of the token error message. How do I generate a proper token for the URL query string? Link to comment Share on other sites More sharing options...
[email protected] Posted May 3, 2013 Author Share Posted May 3, 2013 I came accross Tools::getAdminToken(), but what do I pass as the string parameter? Link to comment Share on other sites More sharing options...
vekia Posted May 3, 2013 Share Posted May 3, 2013 what you exactly have got in the {$token} variable? Link to comment Share on other sites More sharing options...
[email protected] Posted May 3, 2013 Author Share Posted May 3, 2013 Nothing significant, I tried another token from the previous page, but it obviously needs to be generated. Pretty certain it's got to do with Tools::getAdminToken(). Link to comment Share on other sites More sharing options...
vekia Posted May 4, 2013 Share Posted May 4, 2013 Nothing significant, I tried another token from the previous page, but it obviously needs to be generated. Pretty certain it's got to do with Tools::getAdminToken(). you can also use this: {$smarty.get.token} Link to comment Share on other sites More sharing options...
Trip Posted May 4, 2013 Share Posted May 4, 2013 (edited) For my ajax product updates I use these tokens.. maybe they get you in the right direction To open a products page logged in I use $tokenProducts = Tools::getAdminToken('AdminProducts'.intval(Tab::getIdFromClassName('AdminProducts')).intval($cookie->id_employee)); To send a validation token via ajax to a module I use: $token = Tools::getAdminToken('AdminModules'.intval(Tab::getIdFromClassName('AdminModules')).intval($cookie->id_employee)); Best regards, trip Edited May 4, 2013 by Trip (see edit history) 3 Link to comment Share on other sites More sharing options...
[email protected] Posted May 6, 2013 Author Share Posted May 6, 2013 Thanks guys! You both got me in the right direction. Problem has been sorted. Because I'm visiting another Controller class from within my Module, I used @Trip's example. Link to comment Share on other sites More sharing options...
vekia Posted May 6, 2013 Share Posted May 6, 2013 Great information! Thanks for it. Now i can go ahead and mark this thread as solved regards Link to comment Share on other sites More sharing options...
Vipul Hadiya Posted December 7, 2014 Share Posted December 7, 2014 Great information! Thanks for it. Now i can go ahead and mark this thread as solved regards What should i do if i want to link any order page to my module. I means i set link for each order in my module and set token using both Tools::getAdminToken('AdminOrders'.intval(Tab::getIdFromClassName('AdminOrders')).intval($cookie->id_employee)) and Tools::getAdminToken('MymoduleClass'.intval(Tab::getIdFromClassName('MymoduleClass')).intval($cookie->id_employee)) but each time i get error INVALID SECURITY TOKEN Link to comment Share on other sites More sharing options...
Recommended Posts