Answer the question
In order to leave comments, you need to log in
How to reload the page correctly if the user is deleted?
there is a function to delete a user
public function delete(Request $request)
{
$params = $request->request->all();
foreach ($params as $param){
$item = $this->getDoctrine()->getManager();
$user = $item->getRepository(User::class)->find($param);
$item->remove($user);
$item->flush();
}
return $this->redirect('main');
}
Answer the question
In order to leave comments, you need to log in
In symphony, user data is recorded in the session and validated with any data change. Accordingly, when the user is deleted by itself, the validator is lost and this error falls out. The easiest way would be to take in the
SessionInterface $session as well, and then clear the session:public function delete
$this->get('security.token_storage')->setToken(null);
$session->invalidate();
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question