简体   繁体   English

FosUserBundle和自定义用户注册

[英]FosUserBundle and custom user registration

I am trying to figure out the registration process of the FosUserBundle and have been unable to do so. 我试图弄清楚FosUserBundle的注册过程,但一直无法做到。

I want to be able to register a user manually using custom fields and have been unable to see that in the code. 我希望能够使用自定义字段手动注册用户,并且无法在代码中看到该用户。

I have the registerAction in FosUserBundle and following it anywhere does not show me where the information is actually stored in the database: 我在FosUserBundle中有registerAction,并且跟随它在任何地方都没有显示信息实际存储在数据库中的位置:

public function registerAction()
    {
        $form = $this->container->get('fos_user.registration.form');
        $formHandler = $this->container->get('fos_user.registration.form.handler');
        $confirmationEnabled = $this->container->getParameter('fos_user.registration.confirmation.enabled');

        $process = $formHandler->process($confirmationEnabled);
        if ($process) {
            $user = $form->getData();

            if ($confirmationEnabled) {
                $this->container->get('session')->set('fos_user_send_confirmation_email/email', $user->getEmail());
                $route = 'fos_user_registration_check_email';
            } else {
                $this->authenticateUser($user);
                $route = 'fos_user_registration_confirmed';
            }

            $this->setFlash('fos_user_success', 'registration.flash.user_created');
            $url = $this->container->get('router')->generate($route);

            return new RedirectResponse($url);
        }

        return $this->container->get('templating')->renderResponse('FOSUserBundle:Registration:register.html.'.$this->getEngine(), array(
            'form' => $form->createView(),
            'theme' => $this->container->getParameter('fos_user.template.theme'),
        ));
    }

How do I register a user manually? 如何手动注册用户?

Thanks 谢谢

Have you read this in the FOSUserBundle docs? 你有没有在FOSUserBundle文档中读到这个?

Using the UserManager 使用UserManager

Apparently the service UserManager has the responsibility to actually save and update the user, you could create your own UserManager by following the guide. 显然,服务UserManager有责任实际保存和更新用户,您可以按照指南创建自己的UserManager。

Edit: Symfony has incorporated the documentation for the FOSUserBundle into their own documentation, as so the new link for the documentation is: https://symfony.com/doc/master/bundles/FOSUserBundle/index.html 编辑:Symfony已将FOSUserBundle的文档合并到他们自己的文档中,因此文档的新链接是: https ://symfony.com/doc/master/bundles/FOSUserBundle/index.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 无法自定义注册FOSUserBundle - Could not the custom registration FOSUserBundle Symfony2:如何实现自定义用户登录和注册 - 摆脱FOSUSerBundle - Symfony2: how to implement custom user login & registration - get rid of FOSUSerBundle Symfony2 FOSUserBundle自定义注册字段 - Symfony2 FOSUserBundle custom registration field Symfony 3:FosUserBundle使用自定义html类自定义注册表单 - Symfony 3: FosUserBundle Customizing registration form using custom html classes 无法加载类型“ acme_user_registration”的FOSUserBundle - Could not load type “acme_user_registration” FOSUserBundle Symfony 2和FOSUserBundle-在注册过程中从路径向用户添加信息 - Symfony 2 and FOSUserBundle - add information from path to User during registration Symfony2 FOSUserBundle禁用,电子邮件确认和用户注册 - Symfony2 FOSUserBundle disable both, email confirmation and user on registration Symfony2-FOSUserBundle注册后设置用户实体字段 - Symfony2 - FOSUserBundle set user entity field after registration 在FOSUserBundle中,如何在REGISTRATION_COMPLETED事件中初始设置用户角色? - In FOSUserBundle, How to initially set user role on REGISTRATION_COMPLETED event? FOSUserBundle中的EmailConfirmationListener不重定向到fos_user_registration_check_email - EmailConfirmationListener in FOSUserBundle not redirecting to fos_user_registration_check_email
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM