Using passwords hashed in CakePHP in Laravel envir

2019-06-10 23:16发布

Currently I am working on rebuilding an existing website, the old site was written in CakePHP but the new one is in Laravel.

The old users will have to be able to login with the same password as they used on the old site, but those passwords were hashed in CakePHP.

My question is:

Is there a method which would enable me use the CakePHP way of passwordhashing in Laravel?

I have tried looking for a package that could accomplish this, but to no avail.

1条回答
Viruses.
2楼-- · 2019-06-11 00:04

I had a similar issue with a migration from a Drupal site. So it should be applicable here, I'll use CakePHP from now on instead of Drupal. I don't know if you are using a package like Sentry to handle the User accounts, or if it is something homegrown.

What I ended up doing was adding a second password field (cakephp_password) to my users table which contained the imported hashed passwords.

Then during the login process, I checked if the cakephp_password field was empty or not. If it was I passed the password typed by the user through the CakePHP hash function which I added to my Class that handled the logins. I then compared the hash from the CakePHP function with the hash in cakephp_password. If the hashes matched I passed the users password through the hashing function of my laravel User management class (Sentry in my case) and added the calculated hash to the password field of the user and deleted the hash in the cakephp_password field.

Now I could just call the login process normally as for any user.

查看更多
登录 后发表回答