Jump to content

Admin Token 1.7.2.2


Recommended Posts

Hello!

I'm working on Admin module and I have to add field to a product page. Since product page cannot be extended in this version, I have to work on hooks and Javascript. My issue is, I've done what I was supposed to do, however I'm failing to go through token validation.

I'm on site https://myserver.eu/admin/index.php/product/form/12?_token=TyEoISTXRQCH5Bv-Odi9IpTihpvzVIjFn7tQfDZDj6Q#tab-step3

And sending AJAX to https://myserver.eu/admin/index.php?controller=AdminMyModuleController&method=ajaxMyCustomMethod&token=d054ee102bdc9bb4bdf523478ea64b4f&

In JS i retrieve token like this:

       $.ajax({ 
            ajax : true,
            url: `https://myserver.eu/admin/index.php?controller=AdminMyModuleController&method=ajaxMyCustomMethod&token=` + window.employee_token,
            type: 'GET',
            contentType: 'application/json',
            data: JSON.stringify(data),
            dataType: 'json',
            success: 'success',
            error: function () { 
                response([]);
            }
        });

However I'm receiving invalid Token error in response.

Can it be I'm retrieving token while being on site of another controller, and I'm sending AJAX to my controller, therefore (if token is generated from url or controller name) sent Token is different then expected one? So far I have failed to search where is token generated when it needs to be sent from JS file, so I don't know how it is generated, I only assume it is somehow from address. So far, I've found that Presta is using Bloodhound search engine, so I only found their tokenizers.

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...