Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- An exception occurred while executing 'INSERT INTO fos_user (username, username_canonical, email, email_canonical, enabled, salt, password, last_login, locked, expired, expires_at, confirmation_token, password_requested_at, roles, credentials_expired, credentials_expire_at, sex) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)' with params [null, null, null, null, 1, "np04lzt9veo4ow8kc88w8ocgsc4sg4g", null, null, 0, 0, null, null, null, "a:0:{}", 0, null, "Homme"]:
- SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'username' cannot be null
- namespace BISSAPUserBundleController;
- use FOSUserBundleFOSUserEvents;
- use FOSUserBundleEventFormEvent as FormEvent;
- use FOSUserBundleEventGetResponseUserEvent;
- use FOSUserBundleEventFilterUserResponseEvent;
- use SymfonyBundleFrameworkBundleControllerController;
- use SymfonyComponentHttpFoundationRequest;
- use SymfonyComponentHttpFoundationRedirectResponse;
- use SymfonyComponentHttpKernelExceptionNotFoundHttpException;
- use SymfonyComponentSecurityCoreExceptionAccessDeniedException;
- use FOSUserBundleModelUserInterface;
- use BISSAPUserBundleEntityUser;
- use BISSAPUserBundleFormRegistrationType as Register;
- /**
- * Controller managing the registration
- *
- * @author Thibault Duplessis <thibault.duplessis@gmail.com>
- * @author Christophe Coevoet <stof@notk.org>
- */
- class RegistrationController extends Controller
- {
- public function registerAction(Request $request)
- {
- /** @var $formFactory FOSUserBundleFormFactoryFactoryInterface */
- $formFactory = $this->get('fos_user.registration.form.factory');
- /** @var $userManager FOSUserBundleModelUserManagerInterface */
- $userManager = $this->get('fos_user.user_manager');
- /** @var $dispatcher SymfonyComponentEventDispatcherEventDispatcherInterface */
- $dispatcher = $this->get('event_dispatcher');
- $user = $userManager->createUser();
- $user->setEnabled(true);
- $event = new GetResponseUserEvent($user, $request);
- $dispatcher->dispatch(FOSUserEvents::REGISTRATION_INITIALIZE, $event);
- if (null !== $event->getResponse()) {
- return $event->getResponse();
- }
- $form = $this->createForm(Register::Class, $user, array('allow_extra_fields' =>true));
- //$form = $formFactory->createForm();
- $form->setData($user);
- $form->handleRequest($request);
- $ERR = $form->getErrors();
- if ($form->isValid()) {
- // dump($user);
- // die();
- $event = new FormEvent($form, $request);
- $dispatcher->dispatch(FOSUserEvents::REGISTRATION_SUCCESS, $event);
- $userManager->updateUser($user);
- if (null === $response = $event->getResponse()) {
- $url = $this->generateUrl('fos_user_registration_confirmed');
- $response = new RedirectResponse($url);
- }
- $dispatcher->dispatch(FOSUserEvents::REGISTRATION_COMPLETED, new FilterUserResponseEvent($user, $request, $response));
- return $response;
- }
- return $this->render('BISSAPUserBundle:Registration:register.html.twig', array(
- //return $this->render('BISSAPBenevolesBundle:Default:index.html.twig', array(
- 'form' => $form->createView(),'ERR' => $ERR
- ));
- }
- /**
- * Tell the user to check his email provider
- */
- public function checkEmailAction()
- {
- $email = $this->get('session')->get('fos_user_send_confirmation_email/email');
- $this->get('session')->remove('fos_user_send_confirmation_email/email');
- $user = $this->get('fos_user.user_manager')->findUserByEmail($email);
- if (null === $user) {
- throw new NotFoundHttpException(sprintf('The user with email "%s" does not exist', $email));
- }
- return $this->render('FOSUserBundle:Registration:checkEmail.html.twig', array(
- 'user' => $user,
- ));
- }
- /**
- * Receive the confirmation token from user email provider, login the user
- */
- public function confirmAction(Request $request, $token)
- {
- /** @var $userManager FOSUserBundleModelUserManagerInterface */
- $userManager = $this->get('fos_user.user_manager');
- $user = $userManager->findUserByConfirmationToken($token);
- if (null === $user) {
- throw new NotFoundHttpException(sprintf('The user with confirmation token "%s" does not exist', $token));
- }
- /** @var $dispatcher SymfonyComponentEventDispatcherEventDispatcherInterface */
- $dispatcher = $this->get('event_dispatcher');
- $user->setConfirmationToken(null);
- $user->setEnabled(true);
- $event = new GetResponseUserEvent($user, $request);
- $dispatcher->dispatch(FOSUserEvents::REGISTRATION_CONFIRM, $event);
- $userManager->updateUser($user);
- if (null === $response = $event->getResponse()) {
- $url = $this->generateUrl('fos_user_registration_confirmed');
- $response = new RedirectResponse($url);
- }
- $dispatcher->dispatch(FOSUserEvents::REGISTRATION_CONFIRMED, new FilterUserResponseEvent($user, $request, $response));
- return $response;
- }
- /**
- * Tell the user his account is now confirmed
- */
- public function confirmedAction()
- {
- $user = $this->getUser();
- if (!is_object($user) || !$user instanceof UserInterface) {
- throw new AccessDeniedException('This user does not have access to this section.');
- }
- return $this->render('FOSUserBundle:Registration:confirmed.html.twig', array(
- 'user' => $user,
- 'targetUrl' => $this->getTargetUrlFromSession(),
- ));
- }
- private function getTargetUrlFromSession()
- {
- // Set the SecurityContext for Symfony <2.6
- if (interface_exists('SymfonyComponentSecurityCoreAuthenticationTokenStorageTokenStorageInterface')) {
- $tokenStorage = $this->get('security.token_storage');
- } else {
- $tokenStorage = $this->get('security.context');
- }
- $key = sprintf('_security.%s.target_path', $tokenStorage->getToken()->getProviderKey());
- if ($this->get('session')->has($key)) {
- return $this->get('session')->get($key);
- }
- }
- }
- namespace BISSAPUserBundleForm;
- use SymfonyComponentFormAbstractType;
- use SymfonyComponentFormFormBuilderInterface;
- use SymfonyComponentFormExtensionCoreTypeChoiceType;
- use SymfonyComponentFormExtensionCoreTypeButtonType;
- class RegistrationType extends AbstractType
- {
- public function buildForm(FormBuilderInterface $builder, array $options)
- {
- $builder->add('sex', ChoiceType::class, array(
- 'choices' => array(
- 'Homme' => 'Homme',
- 'Femme' => 'Femme',
- 'Unknow' => 'Unknow',
- ),
- ));
- $builder->add('Enregistrer', ButtonType::class, array(
- 'attr' => array(
- 'class' => 'registerbox__submit bc-btn',)));
- }
- /*
- public function getDefaultOptions()
- {
- return array(
- 'validation_groups' => array('registration', 'Default')
- );
- }
- */
- public function setDefaultOptions(OptionsResolverInterface $resolver)
- {
- $resolver->setDefaults(
- array(
- 'allow_extra_fields' => true
- )
- );
- }
- public function getParent()
- {
- return 'FOSUserBundleFormTypeRegistrationFormType';
- }
- public function getBlockPrefix()
- {
- return 'app_user_registration';
- }
- }
- RegistrationController.php on line 61:
- User {#381 ▼
- #id: null
- +sex: "Homme"
- #username: null
- #usernameCanonical: null
- #email: null
- #emailCanonical: null
- #enabled: true
- #salt: "h5asnpkagfcos0w0kc84ksosc40cgwg"
- #password: null
- #plainPassword: null
- #lastLogin: null
- #confirmationToken: null
- #passwordRequestedAt: null
- #groups: null
- #locked: false
- #expired: false
- #expiresAt: null
- #roles: []
- #credentialsExpired: false
- #credentialsExpireAt: null
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement