/**
  * @RPC\Route("/api/auth/login")
  * @RPC\Method("POST")
  */
 public function login()
 {
     $credentials = json_decode($this->request->getContent(), true);
     try {
         v::create()->key('email', v::notEmpty())->key('password', v::notEmpty())->assert($credentials);
     } catch (ValidationException $e) {
         $errors = $e->findMessages(['email', 'password']);
         throw new \pmill\Doctrine\Rest\Exception\ValidationException($errors);
     }
     $password = $credentials['password'];
     unset($credentials['password']);
     /** @var User $user */
     $user = $this->authenticationService->authenticateWithCredentials(User::class, $credentials, $password);
     $token = $this->authenticationService->generateTokenFromObject($user);
     return ['token' => $token];
 }