以编程方式创建JWT令牌

时间:2019-03-23 03:57:01

标签: lexikjwtauthbundle symfony-4.2

  namespace App\Controller;
  use Symfony\Bundle\FrameworkBundle\Controller\Controller;
  use Symfony\Component\HttpFoundation\JsonResponse;
  use Symfony\Component\Security\Core\User\UserInterface;
  use Lexik\Bundle\JWTAuthenticationBundle\Services\JWTTokenManagerInterface;

class ApiController extends Controller
 {
public function getTokenUser(UserInterface $user, JWTTokenManagerInterface $JWTManager)
{
    // ...
            $user = $this->getDoctrine()->getRepository(User::class)-> 
     findOneByEmail($email); 
       return new JsonResponse(['token' => $JWTManager->create($user)]);
   }

}

无法自动装配App \ Controller \ UserController :: recover()的参数$ user“: 它引用接口 Symfony \ Component \ Security \ Core \ User \ UserInterface;

,但不存在此类服务。您是否创建了实现此接口的类? (500个内部服务器错误)

有人可以帮我..谢谢

0 个答案:

没有答案