How can I generate salt and confirm_token entries for relocated users using FOSUserBundle

I am resurrecting a website that has been around for several years and I am porting everything to Symfony2. I was able to get all my old records in the user database in the fos_user table. The only problem is that the salt and confirm_token entries are empty because users were not created in the standard way. I want all users to reset their passwords, so I'm not worried about old hashed passwords in general. How can I generate records for 13,000 users at a time? Maybe I need to redefine the controller to create the salt and confirm_token with every password request? Are there any methods for this? It seems that someone else had this problem before.

thanks

+6
source share
1 answer

I solved this by overriding the fosUserBundle Resetting controller. Instructions can be found here .

I forcibly generated a new toke with these lines:

$tokenGenerator = $this->container->get('fos_user.util.token_generator'); $user->setConfirmationToken($tokenGenerator->generateToken()); 

I was able to generate salt values ​​with a simple SQL query.

 UPDATE fos_user set salt = SUBSTRING(MD5(RAND()) FROM 1 FOR 31) WHERE salt IS NULL 
+9
source

Source: https://habr.com/ru/post/945978/


All Articles