Я могу сделать автоматический вход с помощью fosuserBundle, когда он получает доступ к пункту добавления страницы, он является автоматическим входом в систему, когда он получает доступ к странице добавления статьи, он автоматически перенаправляет на страницу входа, но моя цель — автоматический вход
маршрутизация:
ajouterapps:
path: /ajouterapps
defaults: { _controller: MedBundle:Apps:ajouter }
контроллер кода:
public function ajouterAction()
{
$em = $this->getDoctrine();
$repo = $em->getRepository("UserBundle:User"); //Entity Repository
$user = $this->getUser();
if (!$user) {
throw new UsernameNotFoundException("User not found");
} else {
$token = new UsernamePasswordToken($user, null, "your_firewall_name", $user->getRoles());
$this->get("security.context")->setToken($token); //now the user is logged in
//now dispatch the login event
$request = $this->get("request");
$event = new InteractiveLoginEvent($request, $token);
$this->get("event_dispatcher")->dispatch("security.interactive_login", $event);
}
$msg = 'ajouter Apps';
$em = $this->getDoctrine()->getManager();
$app = new Apps();
$form = $this->createForm(new AppsType, $app);
$request = $this->getRequest();
if ($request->getMethod() == 'POST') {
$form->handleRequest($request);
$app->upload();
$em->persist($app);
$em->flush();
$msg = 'Apps ajouter avec success';
}
return $this->render('MedBundle:Apps:ajouter.html.twig',array(
'form'=>$form->createView(),
'msg'=>$msg
)
);
}
Какое решение и спасибо заранее
Задача ещё не решена.
Других решений пока нет …