Symfony 2 authentication with (doctrine) Entity

前端 未结 1 461
名媛妹妹
名媛妹妹 2020-12-16 04:48

I think I\'ve tried all code in all posts about authentication with (doctrine) Entity in Symfony 2. And I can`t make it work. When I use in_memory provider all works fine. I

相关标签:
1条回答
  • 2020-12-16 05:11

    Finally somebody helped me. The issue is that I wasn't using any salt to create the password, and in the getSalt function of the User class I was returning the ID.

    The password is generated like this (in the controller):

    $factory = $this->container->get('security.encoder_factory');
    $encoder = $factory->getEncoder($user);
    $pwd = $encoder->encodePassword('your_random_password', $user->getSalt());
    $user->setPassword($pwd);
    
    0 讨论(0)
提交回复
热议问题