public function proceed($userId, $tokenHash) { /** @var UserInterface $user */ $user = $this->userRepository->findOneBy(array('id' => new \MongoId($userId), 'tokens.hash' => $tokenHash)); if (!$user) { throw new UserNotFoundException('User or token does not exists'); } $this->checkAllTokens($user, $tokenHash); $this->authenticationService->getStorage()->write($user->getId()); }