Jump to content

secure_key how to generate it?


Recommended Posts

Hello to all,
I created a user registration form for the BackOffice that records, in fact, users and goes to compile also other personal tables in the database.
Now I find myself with a problem, the scure_key field in the ps_customer table.
How can I generate the string secure_key?
I was hoping for something like the password that is generated by encrypting in MD5 the queuing of COOKIE_KEY + Password but ... apparently not.
It seems that without this key the user can not make orders, in fact by mistake.

I await your
thank you so much


PS version: 1.7

Link to comment
Share on other sites

6 ore fa, jgamio dice:

You can check the Prestashop code

 

go to classes/Customer.php then look on the add part

Hi, Thank you for your answer.

I checked, but I can't understand how ps generate it...
At line 242 you can see this:
 

$this->secure_key = md5(uniqid(rand(), true));

But if I insert this string into my personal code doesn't work for Prestashop...

This sim a random string in MD5... How prestashop check is correct if is random?

Link to comment
Share on other sites

35 minuti fa, jgamio dice:

Sorry I am lost about what do you need

Maybe I am wrong but these is just an internal code to use for example to validate an Order , that is why is a ramdom

 

Where do you got errors ?

 

Sometimes the payment fail and PS show and error.
But the user that I created with my method can't see category as attached, the user  that I create trought PS form in BackOffice don't have this problem.

image.thumb.png.ca4c3512f3009a8362a15c376cbc44a7.png
The red message says "You don't have access to this category"

Link to comment
Share on other sites

No, the customers are all in the same group... But if I create the suer with my form it doesn't work and if I use PrestaShop all is fine.

I'll send you ps_customer difference from user created with my form and with prestashop.
Do you need also my registration code?

Edited by webmachine (see edit history)
Link to comment
Share on other sites

Ok, I checked...
The user have a group but when I create user with my form it can't see category, if I go to Customer--> on BO, open the user created and click SAVE... The user can see the category.
On db the only field that change after saving is Password.
Password before saving: 17b6c299ef10e8d9f1a5f455010ee710

Password afert saving: $2y$10$YI.BuNSyb.LMvPba.4c/DucgJEXpFNtNg2rS/18ZHpp52UU2/GZhi

PS crypt the psw again... Why? How can I crypt with the same method
But in both cases the user can login, the password "change" but remain the same for PS.

Link to comment
Share on other sites

You need check why you got the Non hai accesso a questa categoria

You talk about the secury key or the password but you just doing guess

 

1- Go to the Categoty Controller

on the  init  you got a checkaccess function to the class

 

2- Go to the Category class search checkaccess function

 

The function dont use the password or the secure key but there you can see the query just check agains your data to find the problem

 

 

 

 

Link to comment
Share on other sites

9 minuti fa, jgamio dice:

1- Go to the Categoty Controller

Hi,
I found $customer_access, the file says this:
 

    /** @var bool If set to false, customer cannot view the current category. */
    public $customer_access = true;


Now... Where is set $customer_access ? What is?

Link to comment
Share on other sites

  • 2 years later...

Just for the future users, we had a problem since some users cannot end the order process due to secure_key been null, this happens because those users where updated using webservices and the secure key was overwritten by the PUT method.

 I've managed to create a secure_key using this mysql query:

 

update ps_customer set secure_key=MD5(RAND()) where secure_key = '';

 

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...