Update authorization status of all social services.

@param RecordInterface $user Pointer to authorized user database record
497870
protected function update(RecordInterface &$user)
    {
        // Load user from session
        $this->user = $user;
        $this->authorized = true;

        // Save to session
        $_SESSION[$this->identifier()] = serialize($this->user);

        // Tell all ancestors that we are in
        foreach (self::$ancestors as & $ancestor) {
            $ancestor->user = &$this->user;
            $ancestor->active = &$this;
            $ancestor->authorized = $this->authorized;
        }
    }
813992
public function onAsyncUserCreate(User $user)
    {
        if ($user['groupId']) {
            return;
        }

        $defaultGroupId = wei()->setting('user.defaultGroupId', 0);
        if ($defaultGroupId) {
            $user->updateGroup($defaultGroupId);
        }
    }
577524
public function persist(UserInterface $user)
    {
        $session = new PersistentSession();
        $session->email = $this->email;
        $session->series = $this->hash($this->series);
        $session->token = $this->hash($this->token);
        $session->user_id = $user->id();
        $session->two_factor_verified = $user->isTwoFactorVerified();

        try {
            $session->save();
        } catch (\Exception $e) {
            throw new \Exception("Unable to save persistent session for user # {$user->id()}: ".$e->getMessage());
        }

        return $session;
    }
1245882
public function addUser(AdvancedUserInterface $user)
    {
        $this->users->add($user);
        $user->addOrganization($this);

        return $this;
    }
1052277
public function doAuthentication(UserInterface $user)
    {
        /** @var \PServerCore\Entity\Repository\User $repository */
        $repository = $this->entityManager->getRepository($this->getUserEntityClassName());

        // fix if we have a proxy we don´t have a valid entity, so we have to clear before we can create a new select
        $username = $user->getUsername();
        $repository->clear();

        $userNew = $repository->getUser4UserName($username);

        $authService = $this->getAuthService();

        $authService->getStorage()->write($userNew);
    }
1324457
public static function set_user($user): void
	{
		// Sets the history table name
		if ( bbn\str::is_uid($user) ){
			self::$user = $user;
		}
	}
1214676
protected function updateUserFields(UserInterface $user)
    {
        if (null === $this->userDiscriminator) {
            $this->userDiscriminator = $this->container->get('rollerworks_multi_user.user_discriminator');
        }

        // Can only use the user manager when there is an user-system active
        if (null === $this->userDiscriminator->getCurrentUser() || true !== $this->userDiscriminator->getCurrentUserConfig()->getConfig('use_listener', true)) {
            return;
        }

        if (null === $this->userManager) {
            $this->userManager = $this->container->get('fos_user.user_manager');
        }

        $this->userManager->updateCanonicalFields($user);
        $this->userManager->updatePassword($user);
    }
1088606
protected function checkActivation(UserInterface $user)
    {
        $completed = $this->activations->completed($user);

        if (! $completed) {
            $exception = new NotActivatedException('Your account has not been activated yet.');

            $exception->setUser($user);

            throw $exception;
        }
    }
1268762
public function addUserToPerimeter(UserInterface $user, BusinessPerimeterInterface $perimeter)
    {
        $this->perimeterManager->addUserToPerimeter($user->getId(), $perimeter->getId());
    }
918631
protected function authRoles(UserInterface $user)
    {
        if (empty($this->roles)) {
            return true;
        }

        foreach ($this->roles as $role) {
            if ($user->hasRole($role)) {
                return true;
            }
        }

        return false;
    }
1117610
public function update(ServerRequestInterface $request, UserInterface $user): ResponseInterface
    {
        $user_id        = (int) $request->getParsedBody()['user_id'];
        $username       = $request->getParsedBody()['username'];
        $real_name      = $request->getParsedBody()['real_name'];
        $email          = $request->getParsedBody()['email'];
        $password       = $request->getParsedBody()['password'];
        $theme          = $request->getParsedBody()['theme'];
        $language       = $request->getParsedBody()['language'];
        $timezone       = $request->getParsedBody()['timezone'];
        $contact_method = $request->getParsedBody()['contact_method'];
        $comment        = $request->getParsedBody()['comment'];
        $auto_accept    = (bool) ($request->getParsedBody()['auto_accept'] ?? false);
        $canadmin       = (bool) ($request->getParsedBody()['canadmin'] ?? false);
        $visible_online = (bool) ($request->getParsedBody()['visible_online'] ?? false);
        $verified       = (bool) ($request->getParsedBody()['verified'] ?? false);
        $approved       = (bool) ($request->getParsedBody()['approved'] ?? false);

        $edit_user = $this->user_service->find($user_id);

        if ($edit_user === null) {
            throw new NotFoundHttpException(I18N::translate('%1$s does not exist', 'user_id:' . $user_id));
        }

        // We have just approved a user.  Tell them
        if ($edit_user->getPreference('verified_by_admin') !== '1' && $approved) {
            I18N::init($edit_user->getPreference('language'));

            Mail::send(
                Auth::user(),
                $edit_user,
                Auth::user(),
                /* I18N: %s is a server name/URL */
                I18N::translate('New user at %s', WT_BASE_URL),
                view('emails/approve-user-text', ['user' => $edit_user, 'site_url' => WT_BASE_URL]),
                view('emails/approve-user-html', ['user' => $edit_user, 'site_url' => WT_BASE_URL])
            );
        }

        $edit_user
            ->setRealName($real_name)
            ->setPreference('theme', $theme)
            ->setPreference('language', $language)
            ->setPreference('TIMEZONE', $timezone)
            ->setPreference('contactmethod', $contact_method)
            ->setPreference('comment', $comment)
            ->setPreference('auto_accept', (string) $auto_accept)
            ->setPreference('visibleonline', (string) $visible_online)
            ->setPreference('verified', (string) $verified)
            ->setPreference('verified_by_admin', (string) $approved);

        if ($password !== '') {
            $edit_user->setPassword($password);
        }

        // We cannot change our own admin status. Another admin will need to do it.
        if ($edit_user->id() !== $user->id()) {
            $edit_user->setPreference('canadmin', $canadmin ? '1' : '0');
        }

        foreach (Tree::getAll() as $tree) {
            $path_length = (int) $request->getParsedBody()['RELATIONSHIP_PATH_LENGTH' . $tree->id()];
            $gedcom_id   = $request->getParsedBody()['gedcomid' . $tree->id()];
            $can_edit    = $request->getParsedBody()['canedit' . $tree->id()];

            // Do not allow a path length to be set if the individual ID is not
            if ($gedcom_id === '') {
                $path_length = 0;
            }

            $tree->setUserPreference($edit_user, 'gedcomid', $gedcom_id);
            $tree->setUserPreference($edit_user, 'canedit', $can_edit);
            $tree->setUserPreference($edit_user, 'RELATIONSHIP_PATH_LENGTH', (string) $path_length);
        }

        if ($edit_user->email() !== $email && $this->user_service->findByEmail($email) instanceof User) {
            FlashMessages::addMessage(I18N::translate('Duplicate email address. A user with that email already exists.') . $email, 'danger');

            return redirect(route('admin-users-edit', ['user_id' => $edit_user->id()]));
        }

        if ($edit_user->userName() !== $username && $this->user_service->findByUserName($username) instanceof User) {
            FlashMessages::addMessage(I18N::translate('Duplicate username. A user with that username already exists. Please choose another username.'), 'danger');

            return redirect(route('admin-users-edit', ['user_id' => $edit_user->id()]));
        }

        $edit_user
            ->setEmail($email)
            ->setUserName($username);

        return redirect(route('admin-users'));
    }
733558
public function update(User $user)
    {
        $url = 'users/' . $user->getAppuserid();

        return $this->updateObject($url, $user);
    }
255049
public function updateUser(UserInterface $user)
    {
        $user->setChangedValue();
        $this->em->persist($user);
        $this->em->flush();
        return true;
    }
48850
public static function update_policyagreed($user = null) {
        global $DB, $USER, $CFG;
        require_once($CFG->dirroot.'/user/lib.php');

        if (!$user || (is_numeric($user) && $user == $USER->id)) {
            $user = $USER;
        } else if (!is_object($user)) {
            $user = $DB->get_record('user', ['id' => $user], 'id, policyagreed');
        }

        $sql = "SELECT d.id, v.optional, a.status
                  FROM {tool_policy} d
            INNER JOIN {tool_policy_versions} v ON v.policyid = d.id AND v.id = d.currentversionid
             LEFT JOIN {tool_policy_acceptances} a ON a.userid = :userid AND a.policyversionid = v.id
                 WHERE (v.audience = :audience OR v.audience = :audienceall)";

        $params = [
            'audience' => policy_version::AUDIENCE_LOGGEDIN,
            'audienceall' => policy_version::AUDIENCE_ALL,
            'userid' => $user->id
        ];

        $allresponded = true;
        foreach ($DB->get_records_sql($sql, $params) as $policyacceptance) {
            if ($policyacceptance->optional == policy_version::AGREEMENT_COMPULSORY && empty($policyacceptance->status)) {
                $allresponded = false;
            } else if ($policyacceptance->optional == policy_version::AGREEMENT_OPTIONAL && $policyacceptance->status === null) {
                $allresponded = false;
            }
        }

        if ($user->policyagreed != $allresponded) {
            $user->policyagreed = $allresponded;
            $DB->set_field('user', 'policyagreed', $allresponded, ['id' => $user->id]);
        }
    }
767433
public function addOrUpdateUser($user)
    {
            $url = self::makeUserUrl($user->tenantId, $user->username);
            $this->service->prepAndSend($url, array(200, 201), 'PUT', json_encode($user), true, 'application/json', 'application/json');
    }
26743
private function handleAddressIdentity(AddressInterface $address, UserInterface $user)
    {
        if (null === $address->getGender()) {
            $address->setGender($user->getGender());
        }
        if (null === $address->getFirstName()) {
            $address->setFirstName($user->getFirstName());
        }
        if (null === $address->getLastName()) {
            $address->setLastName($user->getLastName());
        }
    }
862419
public function setUser(UserInterface $user)
    {
        Base::instance()->mset([
            static::SESSION_USER => $user->getUsername(),
            static::SESSION_LOGIN => true,
        ]);
        $this->user = $user;
    }