小编Dr *_*eto的帖子

Twig模板内的异常处理

我是symfony2的新手。我的项目有两个实体

    [1] Category and
    [2] Evaluation
Run Code Online (Sandbox Code Playgroud)

并且类别有很多评估,所以问题是当我删除类别然后显示评估然后显示错误

"An exception has been thrown during the rendering of a template ("Entity was not found.") in HfAppBundle:SpecificEvaluations:index.html.twig at line 137. "

在137行上是内容{{evaluation.category.name}}。我也尝试过

    {% if evaluation.category.name is not null %}
        {{evaluation.category.name}}
    {% endif %}
Run Code Online (Sandbox Code Playgroud)

但这也给我同样的错误。有人可以帮忙吗?

谢谢

exception relation symfony twig

5
推荐指数
1
解决办法
4604
查看次数

更改密码不起作用Cakephp 3.0.3

我正在使用cakephp 3.0.3,我正在编写更改用户密码的操作,因为我想将当前密码(由用户输入)与数据库中的现有密码进行比较.但它每次给我不同的哈希,

这是我在用户实体中的密码设置器,

protected function _setPassword($password)
{
    return (new DefaultPasswordHasher)->hash($password);
}
Run Code Online (Sandbox Code Playgroud)

在控制器中,

public function changePassword()
{
    $this->request->data['current_password'] = '123456';

    $user = $this->Users->get(5); //get entity of userId 5
    $existing = $user->password; //display password of user 5 from database

    $user->password = $this->request->data['current_password'];
    $new = $user->password;
}
Run Code Online (Sandbox Code Playgroud)

输出:

'$2y$10$inROlYu/ZKfowe.tTfX48OQ1q4oQBIzq3khzH5.jjITYjAxE3eMtm' //output of $existing, which is 123456 in plain
'$2y$10$A8zHGjCs/G1mlbfpzb6oIuc7TgjqC0ExR6X79kjt.1r64GSTSjpXy' //output of $new
Run Code Online (Sandbox Code Playgroud)

这里两个密码都相同,但我得到了差异.每当我按F5(刷新页面)时哈希.

所以有没有办法比较两个密码,并在cakephp 3.0.3中更改新的密码?

authentication passwords cakephp cakephp-3.0

2
推荐指数
1
解决办法
2076
查看次数