0
我嘗試製作個人資料更新頁面,人們可以更改個人資料的詳細信息。他們需要密碼才能更新配置文件。將用戶插入的密碼轉換爲zfcuser加密的密碼
我使用zfcuser
模塊進行登錄和註冊。 我不知道zfcuser
使用哪種加密技術。
現在我需要比較加密密碼zfcuser
與用戶在配置文件更新時輸入的密碼。
贊,如果user_inserted_password==encrypted_password_in_database
則更新配置文件。
我也試過這個代碼
$bcrypt = new Bcrypt;
$bcrypt->setCost(14);
$pass = $bcrypt->create($newpass);
,但不與數據庫中的加密的密碼相匹配。 最後我用這個代碼,
use ZfcUser\Options\PasswordOptionsInterface;
use Zend\ServiceManager\ServiceManager;
use Zend\ServiceManager\ServiceManagerAwareInterface;
use Zend\ModuleManager\Feature\ServiceProviderInterface;
use ZfcUser\Mapper\UserInterface as UserMapperInterface;
use ZfcBase\EventManager\EventProvider;
use GoalioForgotPassword\Options\ForgotOptionsInterface;
use Zend\Crypt\Password\Bcrypt;
class ReservationsController extends AbstractActionController
{
protected $zfcUserOptions;
public function indexAction()
{
$bcrypt = new Bcrypt;
$bcrypt->setCost($this->getZfcUserOptions()->getPasswordCost());
$pass = $bcrypt->create("test");
echo $pass; exit;
}
public function getZfcUserOptions()
{
if (!$this->zfcUserOptions instanceof PasswordOptionsInterface) {
$this->setZfcUserOptions($this->getServiceManager()->get('zfcuser_module_options'));
}
return $this->zfcUserOptions;
}
}
,但得到這個錯誤。
Zend\Mvc\Controller\PluginManager::get was unable to fetch or create an instance for getServiceManager
應該anybudy有想法?如何在zend2
zfcuser
模塊中加密密碼? 在此先感謝。
謝謝。它的作品適合我。 – hemsbhardiya