Confirm the new user as registered.

@param string $username
@param string $confirmsecret
348002
function user_confirm($username, $confirmsecret) {
        global $DB;

        $user = get_complete_user_data('username', $username);

        if (!empty($user)) {
            if ($user->auth != $this->authtype) {
                return AUTH_CONFIRM_ERROR;

            } else if ($user->secret == $confirmsecret && $user->confirmed) {
                return AUTH_CONFIRM_ALREADY;

            } else if ($user->secret == $confirmsecret) {   // They have provided the secret key to get in
                if (!$this->user_activate($username)) {
                    return AUTH_CONFIRM_FAIL;
                }
                $user->confirmed = 1;
                user_update_user($user, false);
                return AUTH_CONFIRM_OK;
            }
        } else {
            return AUTH_CONFIRM_ERROR;
        }
    }
965258
public function actionConfirm($search)
    {
        $user = User::findByEmailOrMobile($search);
        if ($user === null) {
            $this->stdout(Yii::t('user', 'User is not found') . "\n", Console::FG_RED);
        } else {
            if ($user->setEmailConfirm()) {
                $this->stdout(Yii::t('user', 'User has been confirmed') . "\n", Console::FG_GREEN);
            } else {
                $this->stdout(Yii::t('user', 'Error occurred while confirming user') . "\n", Console::FG_RED);
            }
        }
    }
1149478
public function addUser($username, $password, array $roles)
    {
        $this->userProvider->createUser(new User($username, $password, $roles));
    }
590309
public function checkUserIsACollaborator(string $username): bool
    {
        $this->getApi()->request($this->getApi()->sprintf('/repos/:owner/:repo/collaborators/:username',
            $this->getRepositories()->getOwner(), $this->getRepositories()->getRepo(), $username));

        if ($this->getApi()->getHeaders()['Status'] == '204 No Content') {
            return true;
        }

        return false;
    }
408397
public function confirmSecret()
    {
        $secret = $this->owner->{$this->secretAttribute};
        if (empty($secret)) {
            $this->owner->addError($this->codeAttribute, Yii::t('yii', 'The secret is empty.'));
        } else {
            $this->otp->setSecret($secret);
            if (!$this->secretConfirmed()) {
                $this->owner->addError($this->codeAttribute, Yii::t('yii', 'The code is incorrect.'));
            }
        }
    }
233168
public function iAmLoggedInAsUser(string $username)
    {
        $found_user = $this->getUserByName($username);

        $this->logIn($found_user['username'], $found_user['password']);
    }
876269
protected function _loginUser($username, $data = array())
    {
        $data['username'] = $username;

        $parameter        = JFactory::getApplication()->isAdmin() ? 'admin_language' : 'language';
        $data['language'] = $this->getObject('user.provider')->load($username)->get($parameter);

        $options = $this->_options;

        JPluginHelper::importPlugin('user');
        $results = JFactory::getApplication()->triggerEvent('onUserLogin', array($data, $options));

        // The user is successfully logged in. Refresh the current user.
        if (in_array(false, $results, true) == false)
        {
            parent::_loginUser($username);
            return true;
        }

        return false;
    }
829667
public function EmailConfirm($UserID, $EmailKey = '') {
      $User = $this->UserModel->GetID($UserID);
      
      if (!$User)
         throw NotFoundException('User');

      $EmailConfirmed = $this->UserModel->ConfirmEmail($User, $EmailKey);
      $this->Form->SetValidationResults($this->UserModel->ValidationResults());

      if ($EmailConfirmed) {
         $UserID = GetValue('UserID', $User);
         Gdn::Session()->Start($UserID);
      }

      $this->SetData('EmailConfirmed', $EmailConfirmed);
      $this->SetData('Email', $User->Email);
      $this->Render();
   }
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;
    }
1153076
protected function _loginUser($username, $data = array())
    {
        //Set user data in context
        $data = $this->getObject('user.provider')->load($username)->toArray();
        $data['authentic'] = true;

        $this->getObject('user')->setData($data);

        // Explicitly authenticate user
        $this->getObject('user')->setAuthentic();

        return true;
    }
867351
public function iShouldNotBeAbleToLogInAsUser(string $username)
    {
        try {
            $this->iAmLoggedInAsUser($username);
        } catch (ExpectationException $e) {
            // Expectation fulfilled.
            return;
        } catch (RuntimeException $e) {
            // Expectation fulfilled.
            return;
        }

        throw new ExpectationException(
            sprintf(
                '[W802] The user "%s" was logged-in succesfully. This should not have happened.',
                $username
            ),
            $this->getSession()->getDriver()
        );
    }
195319
public function register(array $credentials, $activate)
    {
        try
        {
            if ( $this->validator->with($credentials)->passes() )
            {
                $this->users->register($credentials,$activate);
                return true;
            }
        }
        catch (LoginRequiredException $e)
        {
            $this->validator->add('LoginRequiredException',$e->getMessage());
        }
        catch (PasswordRequiredException $e)
        {
            $this->validator->add('PasswordRequiredException',$e->getMessage());
        }
        catch (UserExistsException $e)
        {
            $this->validator->add('UserExistsException',$e->getMessage());
        }

        return false;
    }
226609
public static function create($userIdentifier, $secretKey, $logger = null)
    {
        $client = self::initializeHttpClient(self::ENDPOINT_URL);

        return new self($userIdentifier, $secretKey, $client, $logger);
    }
1017305
protected function validateData(User $user, $username, $password, $passwordConfirmed)
    {
        $errors = array();
        
        // Username
        if ($this->isUsernameInUse($username, $user)) {
            $errors[] = new Error(Error::GENERAL_ERROR, $this->translate('The username is already in use.', '\\Zepi\\Web\\AccessControl'));
        }        
        
        // If the user is new or the password is not empty we need to validate
        // the password.
        if ($this->shouldValidatePassword($user, $password)) {
            // Password
            if (strlen($password) < 8) {
                $errors[] = new Error(Error::WRONG_INPUT, $this->translate('The password needs at least 8 characters.', '\\Zepi\\Web\\AccessControl'));
            }
            
            if ($password != $passwordConfirmed) {
                $errors[] = new Error(Error::WRONG_INPUT, $this->translate('The passwords are not equal.', '\\Zepi\\Web\\AccessControl'));
            }
        }
        
        if (count($errors) > 0) {
            return $errors;
        }
        
        return true;
    }
1185359
@Override
	void confirmLogin(String token, String username, String password)
			throws IOException, LoginFailedException, MediaWikiApiErrorException {
		super.confirmLogin(token, username, password);
	}
886918
public static function register($username, $email, $password)
    {
        $user = new static;

        $user->username = $username;
        $user->email = $email;
        $user->password = $password;
        $user->joined_at = Carbon::now();

        $user->raise(new Registered($user));

        return $user;
    }
238726
protected static function sendConfirmation($user, $emailServiceId, $emailTemplateId, $deleteOnError = true)
    {
        try {
            if (empty($emailServiceId)) {
                throw new InternalServerErrorException('No email service configured for user invite. See system configuration.');
            }

            if (empty($emailTemplateId)) {
                throw new InternalServerErrorException("No default email template for user invite.");
            }

            /** @var EmailServiceInterface $emailService */
            $emailService = ServiceManager::getServiceById($emailServiceId);
            /** @var EmailTemplate $emailTemplate */
            /** @noinspection PhpUndefinedMethodInspection */
            $emailTemplate = EmailTemplate::find($emailTemplateId);

            if (empty($emailTemplate)) {
                throw new InternalServerErrorException("No data found in default email template for user invite.");
            }

            try {
                $email = $user->email;
                $user->confirm_code = static::generateConfirmationCode(\Config::get('df.confirm_code_length', 32));
                $user->save();
                $templateData = $emailTemplate->toArray();
                $data = array_merge($templateData, [
                    'to'             => $email,
                    'confirm_code'   => $user->confirm_code,
                    'link'           => url(\Config::get('df.confirm_register_url')) .
                        '?code=' . $user->confirm_code .
                        '&email=' . $email .
                        '&username=' . $user->username,
                    'first_name'     => $user->first_name,
                    'last_name'      => $user->last_name,
                    'name'           => $user->name,
                    'email'          => $user->email,
                    'phone'          => $user->phone,
                    'content_header' => array_get($templateData, 'subject', 'Confirm your DreamFactory account.'),
                    'app_name'       => \Config::get('app.name'),
                    'instance_name'  => \Config::get('app.name'), // older templates
                ]);
            } catch (\Exception $e) {
                throw new InternalServerErrorException("Error creating user confirmation.\n{$e->getMessage()}",
                    $e->getCode());
            }

            $bodyText = $emailTemplate->body_text;
            if (empty($bodyText)) {
                //Strip all html tags.
                $bodyText = strip_tags($emailTemplate->body_html);
                //Change any multi spaces to a single space for clarity.
                $bodyText = preg_replace('/ +/', ' ', $bodyText);
            }

            $emailService->sendEmail($data, $bodyText, $emailTemplate->body_html);
        } catch (\Exception $e) {
            if ($deleteOnError) {
                $user->delete();
            }
            throw new InternalServerErrorException("Error processing user confirmation.\n{$e->getMessage()}",
                $e->getCode());
        }
    }