/** * @param User $user */ public function manualLogin(User $user) { $token = new UsernamePasswordToken($user, null, "main", $user->getGroupRoles()); $this->tokenStorage->setToken($token); //now dispatch the login event $event = new InteractiveLoginEvent($this->requestStack->getMasterRequest(), $token); $this->eventDispatcher->dispatch("security.interactive_login", $event); }