无法在symfony中验证正确的用户名和密码

问题描述

我已经使用以下代码行来创建用户

$newUser = new User();
$plainPassword = 'test';
$hashPassword = $this->passwordEncoder->encodePassword($newUser,$plainPassword);

$newUser->setUserName($filterarray['username']);
$newUser->setPassword($hashPassword);
$newUser->setCreatedDatetime();
$newUser->setStatus('active');

$this->entityManager->persist($newUser);
$this->entityManager->flush();

现在当我尝试登录

$this->passwordEncoder->isPasswordValid($user,$credentials->getpassword())

此行始终返回false。这里$user输出

App\Entity\User {#592
  -id: 1
  -loginName: "test"
  -loginPassword: "$2y$13$S5nEPTFznoemyO1.WsBxl.beyGL4i1YuwteDx7GDtzP"
  -createdDatetime: DateTime @1602489653 {#596
    date: 2020-10-12 10:00:53.0 Europe/Berlin (+02:00)
  }
  -status: "active"
}

有人可以帮我吗?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)