Jump to content

Edit History

Bruno G

Bruno G

I have a issue I am stuck on for 3 days now.

I created a controller in a module (modulename/src/Controller) with the new Symfony system :

class TestController extends FrameworkBundleAdminController
{
    public static function getTest(){
        return new JsonResponse("test);
    }
}

And then declared the route in routes.yml as following:

getTest:
  path: mymodule/gettest
  methods: [GET]
  defaults:
    _controller: 'Mymodule\Controller\TestController::getTest'

When I call the URI adminfolder/modules/mymodule/gettest everything works fine but ONLY if i have the token of the module list page "http://...../adminfolder/index.php/improve/modules/manage"

The aim of this controller is to send a JSON response called by AJAX. The thing is I cant NEVER find how to generate the token. I have tried

Tools::getAdminTokenLite('whatever');

with every possible thing (AdminModules, AdminModulesManage, ModuleController, etc etc etc) and I never get the same token as I see in the admin module list page and I can't find how to get it even from my back office admin module. The token itself doesn't even lpooks the same : I get tokens like ..8ee59a385ba5225cc52b.. with the Tools::getAdminTokenLite() method and the token in http://...../adminfolder/index.php/improve/modules/manage looks like LettERSOnLYWithCaps-a_CapsLowAnd1234_CAPSAND123.

The only place I can find this token is in $_SESSION as a csrf_token, but as it appears in links of admin menu tab (when you click on "modules" tab), its taken from somewhere, but where ?

Could you tell me how to get this token that I can use it to reach my endpoint from ajax please ?

Bruno G

Bruno G

I have a issue I am stuck on for 3 days now.

I created a controller in a module (modulename/src/Controller) with the new Symfony system :

class TestController extends FrameworkBundleAdminController
{
    public static function getTest(){
        return new JsonResponse("test);
    }
}

And then declared the route in routes.yml as following:

getTest:
  path: mymodule/gettest
  methods: [GET]
  defaults:
    _controller: 'Mymodule\Controller\TestController::getTest'

When I call the URI adminfolder/modules/mymodule/gettest everything works fine but ONLY if i have the token of the module list page "http://...../adminfolder/index.php/improve/modules/manage"

The aim of this controller is to send a JSON response called by AJAX. The thing is I cant NEVER find how to generate the token. I have tried

Tools::getAdminTokenLite('whatever');

with every possible thing (AdminModules, AdminModulesManage, ModuleController, etc etc etc) and I never get the same token as I see in the admin module list page and I can't find how to get it even from my back office admin module. The token itself doesn't even lpooks the same : I get tokens like ..8ee59a385ba5225cc52b.. with the Tools::getAdminTokenLite() method and the token in http://...../adminfolder/index.php/improve/modules/manage looks like LettERSOnLYWithCaps-a_CapsLowAnd1234_CAPSAND123.

Could you tell me how to get this token that I can use it to reach my endpoint from ajax please ?

×
×
  • Create New...