Registers user on the site.

@throws \Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException if user does not have permission
499543
public function register(Request $request): Response
    {
        $contentTypeIdentifier = $this->getConfigResolver()->getParameter('user.content_type_identifier', 'ngsite');
        $contentType = $this->getRepository()->getContentTypeService()->loadContentTypeByIdentifier($contentTypeIdentifier);
        $languages = $this->getConfigResolver()->getParameter('languages');
        $userCreateStruct = $this->userService->newUserCreateStruct(
            null,
            null,
            null,
            $languages[0],
            $contentType
        );

        $userCreateStruct->enabled = (bool) $this->getConfigResolver()->getParameter('user.auto_enable', 'ngsite');
        $userCreateStruct->alwaysAvailable = (bool) $contentType->defaultAlwaysAvailable;

        $data = new DataWrapper($userCreateStruct, $userCreateStruct->contentType);

        $formBuilder = $this->formFactory->createBuilder(
            CreateUserType::class,
            $data,
            [
                'translation_domain' => 'ngsite_user',
            ]
        );

        $form = $formBuilder->getForm();
        $form->handleRequest($request);

        if (!$form->isValid()) {
            return $this->render(
                $this->getConfigResolver()->getParameter('template.user.register', 'ngsite'),
                [
                    'form' => $form->createView(),
                ]
            );
        }

        $users = $this->userService->loadUsersByEmail($form->getData()->payload->email);

        if (!empty($users)) {
            return $this->render(
                $this->getConfigResolver()->getParameter('template.user.register', 'ngsite'),
                [
                    'form' => $form->createView(),
                    'error' => 'email_in_use',
                ]
            );
        }

        try {
            $this->userService->loadUserByLogin($form->getData()->payload->login);

            return $this->render(
                $this->getConfigResolver()->getParameter('template.user.register', 'ngsite'),
                [
                    'form' => $form->createView(),
                    'error' => 'username_taken',
                ]
            );
        } catch (NotFoundException $e) {
            // do nothing
        }

        $userGroupId = $this->getConfigResolver()->getParameter('user.user_group_content_id', 'ngsite');

        $preUserRegisterEvent = new UserEvents\PreRegisterEvent($data->payload);
        $this->eventDispatcher->dispatch(SiteEvents::USER_PRE_REGISTER, $preUserRegisterEvent);
        $data->payload = $preUserRegisterEvent->getUserCreateStruct();

        /** @var \eZ\Publish\API\Repository\Values\User\User $newUser */
        $newUser = $this->getRepository()->sudo(
            static function (Repository $repository) use ($data, $userGroupId): User {
                $userGroup = $repository->getUserService()->loadUserGroup($userGroupId);

                return $repository->getUserService()->createUser(
                    $data->payload,
                    [$userGroup]
                );
            }
        );

        $userRegisterEvent = new UserEvents\PostRegisterEvent($newUser);
        $this->eventDispatcher->dispatch(SiteEvents::USER_POST_REGISTER, $userRegisterEvent);

        if ($newUser->enabled) {
            return $this->render(
                $this->getConfigResolver()->getParameter('template.user.register_success', 'ngsite')
            );
        }

        if ($this->getConfigResolver()->getParameter('user.require_admin_activation', 'ngsite')) {
            return $this->render(
                $this->getConfigResolver()->getParameter('template.user.activate_admin_activation_pending', 'ngsite')
            );
        }

        return $this->render(
            $this->getConfigResolver()->getParameter('template.user.activate_sent', 'ngsite')
        );
    }
822483
public function register()
    {
        $this->app->singleton('ChuckSite', function() {
            $site = Site::first();
            if ($site == null) {
                throw new Exception('Whoops! No Site Defined...');
            }
            return new \Chuckbe\Chuckcms\Chuck\Accessors\Site($site, \App::make(SiteRepository::class));
        });
    }
801372
private function registerUsermanagement() {

        $this->app->bind('usermanagement', function($app) {
            return new Usermanagement($app);
        });

        $this->app->bind(
            'Illuminate\Contracts\Auth\Registrar',
            'Lasallecms\Usermanagement\Services\Registrar'
        );
    }
450956
public function register()
    {
        $this->getPermissions()->each(function (Permission $permission) {
            $ability = $permission->slug;
            $policy  = function ($user) use ($permission) {
                return $user->hasRole($permission->roles);
            };

            if (Str::contains($permission->slug, '@')) {
                $policy  = $permission->slug;
                $ability = $permission->name;
            }

            $this->gate->define($ability, $policy);
        });
    }
1236003
protected function registerCacheListener()
    {
        Permission::saved(function () {
            $this->app['cache.store']->forget('permissions.policies');
        });

        Permission::deleted(function () {
            $this->app['cache.store']->forget('permissions.policies');
        });

        Role::saved(function () {
            $this->app['cache.store']->forget('permissions.policies');
        });

        Role::deleted(function () {
            $this->app['cache.store']->forget('permissions.policies');
        });
    }
996191
public function register()
    {
        $this->mergeConfigFrom(__DIR__ . '/../config/authentication.php', 'authentication');

        $this->app->singleton(PasswordResetRepositoryContract::class, function ($app) {
            return new PasswordResetRepository($app['config']);
        });

        $this->app->singleton(UserRepositoryContract::class, function () {
            return new UserRepository();
        });

        $this->registerRegisterUserCommand();
        $this->registerAdminCommand();
        $this->registerBanCommand();
    }
75472
private function assertUserIsLoggedIn()
    {
        $token = $this->securityContext->getToken();

        $isAuthenticated = $token !== null &&
                           $token->isAuthenticated() && 
                           $token->getUser() instanceof User &&
                           $token->getUser()->isCredentialsNonExpired();

        if(!$isAuthenticated){
            throw new AccessDeniedException();
        }
    }
1149930
public function register()
    {
        $this->mergeConfigFrom(
            __DIR__ . '/config/acl.php', 'acl'
        );

        $config = $this->app['config']->get('acl');

        $this->registerAclExceptions($config);
        $this->registerModels($config);

        $this->app->bind(PermissionRepositoryInterface::class, function ($app) use ($config) {
            $permissionModel = array_get($config, 'permission');

            return new PermissionRepository($permissionModel);
        });

        $this->commands(RegisterPermissions::class);
    }
787769
public function registerUser()
    {
        // Create the new user
        $user = $this->user->create($this->getUserFromRequest());

        if (! $user) {
            return $user;
        }

        // Fire the registering event.
        event(new UserRegistering($user));

        // Add the extra details needed to finish them.
        // Add the user details.
        $this->userDetails->create($this->getUserDetailsFromRequest($user));

        // Assign the user to the default group
        $user->assignRole(config('jumpgate.users.default_role'));

        // If we do not require activation, set the user as active.
        if (! config('jumpgate.users.require_email_activation')) {
            $user->setStatus(Status::ACTIVE);
        }

        // Fire the registered event.
        event(new UserRegistered($user));

        return $user;
    }
374042
protected function registerUserResolver()
    {
        $this->app->bind('Nova\Auth\UserInterface', function ($app)
        {
            $callback = $app['auth']->userResolver();

            return call_user_func($callback);
        });
    }
469673
public function register(Request $request)
  {
    $request->rules = $this->rules();
    $request->validate();

    Events::trigger('user.registered', [$user = $this->create($request)]);

    if (Auth::provider($this->provider)::login($user)->status == 'success') {
      $this->sendNotification($user);
      Redirect::to($this->redirectPath(), 200);
    }
  }
45836
public function registerAction()
    {
        $entity  = new PreUser();
        $request = $this->getRequest();
        $form    = $this->createForm(new RegistrationForm(), $entity);
        $form->bindRequest($request);

        if ($form->isValid()) {

            $entity->setRegisteredOn(new \DateTime('now'));
            $em = $this->getDoctrine()->getEntityManager();
            $em->persist($entity);
            $em->flush();

            //Generate Token based on ID assigned
            $entity->setToken(base_convert($entity->getId() + 100000000, 10, 32));
            $em->persist($entity);
            $em->flush();

            return $this->redirect($this->generateUrl('launcher_done', array('token' => $entity->getToken())));

        }

        return array(
            'entity' => $entity,
            'form'   => $form->createView()
        );
    }
576260
public function editAction()
    {
        $user = $this->getUser();
        if (!is_object($user) || !$user instanceof UserInterface) {
            throw new AccessDeniedException('This user does not have access to this section.');
        }
        
        $formProfile = $this->createForm(
            new ProfileFormType($this->container->getParameter('fos_user.model.user.class')),
            $user
        );
        $formPassword = $this->container->get('fos_user.change_password.form');
        
        $formProfile->handleRequest($this->getRequest());
        if ($formProfile->isValid()) {
            $userManager = $this->get('fos_user.user_manager');
            $userManager->updateUser($user);
            $this->container->get('session')->getFlashBag()->set('success', $this->get('translator')->trans('profile.flash.updated', array(), 'FOSUserBundle'));
            return $this->redirect($this->generateUrl('olix_security_profile_edit'));
        }
        
        return $this->container->get('olix.admin')->render('OlixSecurityBundle:Profile:edit.html.twig', null, array(
            'user' => $user,
            'tab'  => 'profile',
            'form' => array(
                'profile'  => $formProfile->createView(),
                'password' => $formPassword->createView(),
            ),
        ));
    }
1098808
public function manageOwnAction(Request $request)
    {
        $securityContext = $this->getSecurityContext();

        if (!$securityContext->getToken()) {
            throw new AccessDeniedException(
                $this->get('translator')->trans(
                    'must_be_logged_in_to_edit_own_settings',
                    array(),
                    'settings'
                )
            );
        }

        $securitySettings = $this->container->getParameter('settings_manager.security');
        if (!$securitySettings['users_can_manage_own_settings']) {
            throw new AccessDeniedException(
                $this->get('translator')->trans(
                    'not_allowed_to_edit_own_settings',
                    array(),
                    'settings'
                )
            );
        }

        $user = $securityContext->getToken()->getUser();

        if (!($user instanceof SettingsOwnerInterface)) {
            //For this to work the User entity must implement SettingsOwnerInterface
            throw new AccessDeniedException();
        }

        return $this->manage($request, $user);
    }
541772
public function editUserRegister()
    {
        $this->controlAccessUserRegister();
        $this->setTitleEditUserRegister();
        $this->setBreadcrumbEditUserRegister();

        $this->submitUserRegister();
        $this->setData('password_limit', $this->user->getPasswordLength());
        $this->outputEditUserRegister();
    }
1370728
public function onRegister()
    {
        try {
            if (!$this->canRegister()) {
                throw new ApplicationException(Lang::get(/*Registrations are currently disabled.*/'rainlab.user::lang.account.registration_disabled'));
            }

            /*
             * Validate input
             */
            $data = post();

            if (!array_key_exists('password_confirmation', $data)) {
                $data['password_confirmation'] = post('password');
            }

            $rules = [
                'email'    => 'required|email|between:6,255',
                'password' => 'required|between:4,255|confirmed'
            ];

            if ($this->loginAttribute() == UserSettings::LOGIN_USERNAME) {
                $rules['username'] = 'required|between:2,255';
            }

            $validation = Validator::make($data, $rules);
            if ($validation->fails()) {
                throw new ValidationException($validation);
            }

            /*
             * Register user
             */
            Event::fire('rainlab.user.beforeRegister', [&$data]);

            $requireActivation = UserSettings::get('require_activation', true);
            $automaticActivation = UserSettings::get('activate_mode') == UserSettings::ACTIVATE_AUTO;
            $userActivation = UserSettings::get('activate_mode') == UserSettings::ACTIVATE_USER;
            $user = Auth::register($data, $automaticActivation);

            Event::fire('rainlab.user.register', [$user, $data]);

            /*
             * Activation is by the user, send the email
             */
            if ($userActivation) {
                $this->sendActivationEmail($user);

                Flash::success(Lang::get(/*An activation email has been sent to your email address.*/'rainlab.user::lang.account.activation_email_sent'));
            }

            /*
             * Automatically activated or not required, log the user in
             */
            if ($automaticActivation || !$requireActivation) {
                Auth::login($user);
            }

            /*
             * Redirect to the intended page after successful sign in
             */
            if ($redirect = $this->makeRedirection(true)) {
                return $redirect;
            }
        }
        catch (Exception $ex) {
            if (Request::ajax()) throw $ex;
            else Flash::error($ex->getMessage());
        }
    }
24502
protected function registerUserEloquent(): void
    {
        $this->app->bind('orchestra.user', function () {
            $model = $this->getConfig('models.user', User::class);

            return new $model();
        });
    }