在Laravel环境中使用密码在CakePHP中进行散列 [英] Using passwords hashed in CakePHP in Laravel environment

查看:100
本文介绍了在Laravel环境中使用密码在CakePHP中进行散列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目前我正在重建现有网站,旧网站是用CakePHP编写的,但新网址是在Laravel。



旧用户必须能够使用与旧网站上使用的密码相同的密码登录,但是这些密码在CakePHP中被散列。



我的问题是:


有没有方法可以让我在Laravel中使用
passwordhashing的CakePHP方法?


$ b $

解决方案

我已经尝试寻找一个可以实现这一点的包,我有一个类似的问题,从Drupal网站迁移。所以它应该适用于这里,我将使用CakePHP从现在开始,而不是Drupal。我不知道您是否使用像 Sentry 这样的软件包来处理用户帐户,或者如果是自己开发的帐户。



我最后在我的users表中添加了第二个密码字段( cakephp_password

然后在登录过程中,我检查了 cakephp_password 字段是否为空。如果我通过 CakePHP散列函数传递了用户输入的密码我添加到我的类处理登录。然后我将CakePHP函数的散列与 cakephp_password 中的散列进行比较。如果哈希匹配我通过我的laravel用户管理类(我的case中的Sentry)的哈希函数传递用户密码,并将计算的哈希添加到用户的密码字段并删除 cakephp_password 字段中的散列。



现在我可以像任何用户一样调用登录过程。


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.

解决方案

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.

这篇关于在Laravel环境中使用密码在CakePHP中进行散列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆