Registers a new user.

@param array $values values to set on user account
@param bool  $verifiedEmail true if the email has been verified

@throws AuthException when the user cannot be created.

@return UserInterface newly created user
974013
public function registerUser(array $values, $verifiedEmail = false)
    {
        $email = array_value($values, 'email');
        $tempUser = $this->getTemporaryUser($email);

        // upgrade temporary account
        if ($tempUser && $this->upgradeTemporaryUser($tempUser, $values)) {
            return $tempUser;
        }

        $userClass = $this->auth->getUserClass();
        $user = new $userClass();

        if (!$user->create($values)) {
            throw new AuthException('Could not create user account: '.implode(', ', $user->getErrors()->all()));
        }

        if (!$verifiedEmail) {
            $this->auth->sendVerificationEmail($user);
        } else {
            // send the user a welcome message
            $user->sendEmail('welcome');
        }

        return $user;
    }
542033
public function register(array $userData)
    {
        $alreadyCreatedUser = $this->findByEmail($userData['email']);

        if ($alreadyCreatedUser) {
            throw new OutOfBoundsException(
                'A user was already created with this email address.',
                self::EMAIL_NOT_UNIQUE
            );
        }

        $userEntity = new UserEntity;
        $userEntity->setEmail($userData['email'])
            ->setPassword($this->hashPassword($userData['password']))
            ->setCreated(time())
            ->setEnabled(true)
            ->setVerified(false);

        $user = $this->userMapper->persist($userEntity);

        $userToken = $this->createUserToken([
            'token_type_id' => TokenEntity::TYPE_VERIFY_REGISTRATION,
            'user_id'       => $user->getId(),
        ]);

        // Create the verify registration email
        $this->verifyRegistrationView->setToken($userToken);

        $email = $this->emailService->createFromArray([
            'recipient_email' => $user->getEmail(),
            'subject'         => 'Verify Your Account',
            'message'         => (string) $this->verifyRegistrationView,
        ]);

        $this->emailService->enqueueSendEmailJob($email);

        return $user;
    }
406948
public function create(array $credentials, $activate = false)
    {
        $user = $this->storeUser($credentials,$activate);
        $this->event->fire('users.create',array($user));

        return $user;
    }
898998
public function create(Contracts\RequiresEmailVerification $user)
    {
        $email = $user->getEmailForVerification();

        $this->deleteExisting($user);

        $token = $this->createNewToken();

        $this->getTable()->insert($this->getPayload($email, $token));

        return $token;
    }
1240244
public function addUser($userLogin, $password, $email, $alias = '', array $optional = [])
    {
        return $this->_request('UsersManager.addUser', [
            'userLogin' => $userLogin,
            'password' => $password,
            'email' => $email,
            'alias' => $alias,
        ], $optional);
    }
879160
public function createUser($username, $password, array $roles = array(), array $scopes = array())
    {
        $user = new \OAuth2\ServerBundle\Entity\User();
        $user->setUsername($username);
        $user->setRoles($roles);
        $user->setScopes($scopes);

        // Generate password
        $salt = $this->generateSalt();
        $password = $this->encoderFactory->getEncoder($user)->encodePassword($password, $salt);

        $user->setSalt($salt);
        $user->setPassword($password);

        // Store User
        $this->em->persist($user);
        $this->em->flush();

        return $user;
    }
1248797
public function createUserWithEmailAndPassword($email, $password): UserRecord
    {
        return $this->createUser(
            Request\CreateUser::new()
                ->withUnverifiedEmail($email)
                ->withClearTextPassword($password)
        );
    }
1207380
public function setUserAccountConfirmationStatus($username, $confirmed = true)
    {
        $this->username = $username;
        $this->getMeta()->confirmed = $confirmed;
        $this->getMeta()->save();
    }
215027
public function createUser($email, $password, $role=User::ROLE_RECRUITER, $fullname="Test Recruiter")
    {
        /* @var Register $service */
        /* @var User $user */
        $repo = $this->getUserRepository();
        $user = $repo->create([]);
        $user->setLogin($email);
        $user->setPassword($password);
        $user->setRole($role);
        $settings = $user->getSettings('Applications');
        
        $expFullName = explode(' ', $fullname);
        $info = $user->getInfo();
        $info->setFirstName(array_shift($expFullName));
        $info->setLastName(count($expFullName)>0 ? implode(' ', $expFullName):'');
        $info->setEmail($email);
        $info->setEmailVerified(true);
        $repo->store($user);
        $repo->getDocumentManager()->refresh($user);
        
        $eventArgs = new LifecycleEventArgs($user, $repo->getDocumentManager());
        $repo->getDocumentManager()->getEventManager()->dispatchEvent(
            Events::postLoad,
            $eventArgs
        );
        /* @var \Core\EventManager\EventManager $events */
        /* @var \Auth\Listener\Events\AuthEvent $event */
        //@TODO: [Behat] event not working in travis
        //$events = $this->coreContext->getEventManager();
        //$event  = $events->getEvent(AuthEvent::EVENT_USER_REGISTERED, $this);
        //$event->setUser($user);
        //$events->triggerEvent($event);
        return $user;
    }
1124725
public function createUser(array $input): User
    {
        User::unguard();

        $user = new User([
            'email' => $input['email'],
            'password' => $input['password'],
            'fullname' => $input['fullname'],
            'status' => User::VERIFIED,
        ]);

        \event('orchestra.install: user', [$user, $input]);

        $user->save();

        return $user;
    }
740263
protected function registerVerifyEmailBroker()
    {
        $this->app->singleton('auth.verify_emails', function ($app) {
            return new VerifyEmailBrokerManager($app);
        });

        $this->app->bind('auth.verify_emails.broker', function ($app) {
            return $app->make('auth.verify_emails')->broker();
        });
    }
751277
public function register()
    {
        $this->loadModel('User.Users');
        $this->Users->fieldable(false);
        $user = $this->Users->newEntity();
        $registered = false;
        $languages = LocaleToolbox::languagesList();

        if ($this->request->data()) {
            $user->set('status', 0);
            $user->accessible(['id', 'token', 'status', 'last_login', 'created', 'roles'], false);
            $user = $this->Users->patchEntity($user, $this->request->data);

            if ($this->Users->save($user)) {
                NotificationManager::welcome($user)->send();
                $this->Flash->success(__d('user', 'Account successfully created, further instructions have been sent to your e-mail address.', ['key' => 'register']));
                $registered = true;
            } else {
                $this->Flash->danger(__d('user', 'Account could not be created, please check your information.'), ['key' => 'register']);
            }
        }

        $this->title(__d('user', 'Registration'));
        $this->set(compact('registered', 'user', 'languages'));
    }
280863
public function verifyEmail()
    {
        $user = $this->_user;
        $user->status = User::STATUS_ACTIVE;
        return $user->save(false) ? $user : null;
    }
320229
public static function register($email, $password, $username)
    {
        $user = new self();

        $user->email = $email;

        $user->password = bcrypt($password);

        $user->username = $username;

        $user->joined = time();

        $user->save();

        return $user;
    }
1023202
public function signInFormSucceeded(Form $form, ArrayHash $values)
	{
		try {
			$this->user->login($values->username, $values->password);
			if ($values->remember) {
				$this->user->setExpiration('+ ' . $this->sessionExpiration, false);
			} else {
				$this->user->setExpiration('+ ' . $this->loginExpiration, true);
			}
			$this->restoreRequest($this->backlink);
			$this->redirect(":{$this->module}:Homepage:");
		} catch (AuthenticationException $e) {
			if ($e->getCode() == IAuthenticator::NOT_APPROVED) {
				$form->addError('cms.user.accountDeactivated');
			} else {
				$form->addError('cms.user.incorrectUsernameOrPassword');
			}
		}
	}
77375
public function registerConfirm(\Swift_Mailer $mailer, EventDispatcherInterface $dispatcher, TranslatorInterface $translator, $token)
    {
        // Get Doctrine
        $em = $this->getDoctrine()->getManager();

        // Find User
        $user = $em->getRepository($this->getParameter('pd_user.user_class'))->findOneBy(['confirmationToken' => $token]);
        if (null === $user) {
            throw $this->createNotFoundException(sprintf($translator->trans('security.token_notfound'), $token));
        }

        // Enabled User
        $user->setConfirmationToken(null);
        $user->setEnabled(true);

        // Send Welcome
        if ($this->getParameter('pd_user.welcome_email')) {
            $this->sendEmail($user, $mailer, 'Registration', 'Welcome', 'Welcome');
        }

        // Update User
        $em->persist($user);
        $em->flush();

        // Dispatch Register Event
        if ($response = $dispatcher->dispatch(UserEvent::REGISTER_CONFIRM, new UserEvent($user))->getResponse()) {
            return $response;
        }

        // Register Success
        return $this->render($this->getParameter('pd_user.template_path') . '/Registration/registerSuccess.html.twig', [
            'user' => $user,
        ]);
    }
1046367
protected function verifiedEmail($user)
    {
        $this->guard()->login($user);

        if(!$user->verified) {
            $user->forceFill([
                'verified' => true
            ])->save();
            return true;
        }

        return false;
    }