Add a link to reset configuration inside the user edit form.

@param User $user
@param FormBuilder $form
499542
protected function extendForm(User $user, FormBuilder $form)
    {
        $areaProviders = $this->twoFactorProviderService->getAreaProvidersCollection();
        $items         = $this->usersPresenter->index($user, $areaProviders);

        if (empty($items)) {
            return;
        }

        $form->extend(function(FormGrid $form) use($items) {
            $fieldsetName = trans('antares/two_factor_auth::configuration.index');

            $form->findFieldsetOrCreateNew($fieldsetName, function(Fieldset $fieldset) use($items) {

                foreach ($items as $item) {
                    $fieldset->control('input:text', '', function($control) use($item) {
                        $control->field(function() use($item) {
                            return array_get($item, 'line');
                        });
                    })->label($item['area']->getLabel());
                }
            });
        });
    }
325806
public function setPlatformRoles(User $user, $roles)
    {
        $this->roleManager->resetRoles($user);
        $this->roleManager->associateRoles($user, $roles);
    }
197266
public function edit(User $user)
    {
        return $this->makeResponse('edit', [
            'user' => $user,
            'roles' => $this->roles,
            'x_fields' => $this->x_fields,
        ]);
    }
613705
protected function sendPasswordResetEmail(User $user)
    {
        $email = $user->email;

        /** @var \DreamFactory\Core\User\Services\User $parent */
        $parent = $this->getService();

        if (!empty($parent->passwordEmailServiceId)) {
            try {
                /** @var EmailServiceInterface $emailService */
                $emailService = ServiceManager::getServiceById($parent->passwordEmailServiceId);

                if (empty($emailService)) {
                    throw new ServiceUnavailableException("Bad email service identifier.");
                }

                $data = [];
                if (!empty($parent->passwordEmailTemplateId)) {
                    // find template in system db
                    $template = EmailTemplate::whereId($parent->passwordEmailTemplateId)->first();
                    if (empty($template)) {
                        throw new NotFoundException("Email Template id '{$parent->passwordEmailTemplateId}' not found");
                    }

                    $data = $template->toArray();
                }

                if (empty($data) || !is_array($data)) {
                    throw new ServiceUnavailableException("No data found in default email template for password reset.");
                }

                $data['to'] = $email;
                $data['content_header'] = 'Password Reset';
                $data['first_name'] = $user->first_name;
                $data['last_name'] = $user->last_name;
                $data['name'] = $user->name;
                $data['phone'] = $user->phone;
                $data['email'] = $user->email;
                $data['link'] = url(\Config::get('df.confirm_reset_url')) .
                    '?code=' . $user->confirm_code .
                    '&email=' . $email .
                    '&username=' . $user->username .
                    '&admin=' . $user->is_sys_admin;
                $data['confirm_code'] = $user->confirm_code;

                $bodyHtml = array_get($data, 'body_html');
                $bodyText = array_get($data, 'body_text');

                if (empty($bodyText) && !empty($bodyHtml)) {
                    $bodyText = strip_tags($bodyHtml);
                    $bodyText = preg_replace('/ +/', ' ', $bodyText);
                }

                $emailService->sendEmail($data, $bodyText, $bodyHtml);

                return true;
            } catch (\Exception $ex) {
                throw new InternalServerErrorException("Error processing password reset.\n{$ex->getMessage()}");
            }
        }

        return false;
    }
470870
protected function updateErrorBox(Form $form, $errors)
    {
        foreach ($form->getChildrenByType('\\Zepi\\Web\\UserInterface\\Form\\ErrorBox', true) as $errorBox) {
            $errorBox->updateErrorBox($form, false, $errors);
        }
    }
1290913
public function updateUser(User $user)
    {
        $query = $this->handler->createUpdateQuery();
        $query
            ->update($this->handler->quoteTable('ezuser'))
            ->set(
                $this->handler->quoteColumn('login'),
                $query->bindValue($user->login)
            )->set(
                $this->handler->quoteColumn('email'),
                $query->bindValue($user->email)
            )->set(
                $this->handler->quoteColumn('password_hash'),
                $query->bindValue($user->passwordHash)
            )->set(
                $this->handler->quoteColumn('password_hash_type'),
                $query->bindValue($user->hashAlgorithm)
            )->where(
                $query->expr->eq(
                    $this->handler->quoteColumn('contentobject_id'),
                    $query->bindValue($user->id, null, \PDO::PARAM_INT)
                )
            );
        $query->prepare()->execute();

        $query = $this->handler->createUpdateQuery();
        $query
            ->update($this->handler->quoteTable('ezuser_setting'))
            ->set(
                $this->handler->quoteColumn('is_enabled'),
                $query->bindValue($user->isEnabled, null, \PDO::PARAM_INT)
            )->set(
                $this->handler->quoteColumn('max_login'),
                $query->bindValue($user->maxLogin, null, \PDO::PARAM_INT)
            )->where(
                $query->expr->eq(
                    $this->handler->quoteColumn('user_id'),
                    $query->bindValue($user->id, null, \PDO::PARAM_INT)
                )
            );
        $query->prepare()->execute();
    }
1369487
public function resetPassword( $user, $resetForm ) {

		$modelClass	= static::$modelClass;

		// Find existing user
		$userToUpdate = $modelClass::findById( $user->id );

		// Generate Password
		$userToUpdate->generatePassword( $resetForm->password );
		$userToUpdate->unsetResetToken();

		// User need admin approval
		if( Yii::$app->core->isUserApproval() ) {

			$userToUpdate->verify();
		}
		// Direct approval and activation
		else {

			$userToUpdate->status = User::STATUS_ACTIVE;
		}

		// Update User
		$userToUpdate->update();

		return $userToUpdate;
	}
1344725
public function update(User $user, Request $request)
    {
        // user we want to edit and session user must be the same
        if ($user->id != user()->id) {
            return redirect()
                ->back()
                ->withInput($request->all())
                ->withErrors(['firstname' => 'Unauthorized access']);
        }

        // submit without a file
        if (is_null($request->file('photo'))) {
            $this->validate($request, array_except(User::$rulesProfile, 'photo'));
        }
        else {
            $this->validate($request, User::$rulesProfile);

            $photo = $this->uploadProfilePicture($request->file('photo'));

            $request->merge(['image' => $photo]);
        }

        // update user without photo and password
        $this->updateEntry($user, $request->only([
            'firstname',
            'lastname',
            'cellphone',
            'telephone',
            'born_at',
            'image'
        ]));

        // update user  password
        if ($request['password'] && strlen($request['password']) >= 2) {
            user()->update([
                'password' => bcrypt($request['password']),
            ]);
        }

        return redirect('/admin/profile');
    }
305042
public function editAccount($user_id)
    {
        $this->setUserAccount($user_id);
        $this->controlAccessEditAccount();
        $this->setTitleEditAccount();
        $this->setBreadcrumbEditAccount();
        $this->setData('user', $this->data_user);

        $this->submitEditAccount();
        $this->outputEditAccount();
    }
713682
private function cleanFtpCredentials(User $user)
    {
        if (null !== $credential = $user->getFtpCredential()) {
            $this->objectManager->remove($credential);
        }
    }
334002
protected function CanEdit(User $user)
    {
        return self::Guard()->Allow(BackendAction::Edit(), $user)&&
            self::Guard()->Allow(BackendAction::UseIt(), new UserForm());
    }
596794
public function changeUserNick(UserEventInterface $event, EventQueueInterface $queue)
    {
        $logger = $this->getLogger();

        $connectionMask = $this->getConnectionMask($event->getConnection());
        $old = $event->getNick();
        $params = $event->getParams();
        $new = $params['nickname'];
        $logger->debug('Changing user nick', array(
            'connectionMask' => $connectionMask,
            'oldNick' => $old,
            'newNick' => $new,
        ));

        foreach (array_keys($this->modes[$connectionMask]) as $channel) {
            if (!isset($this->modes[$connectionMask][$channel][$old])) {
                continue;
            }
            $logger->debug('Moving user mode data', array(
                'connectionMask' => $connectionMask,
                'channel' => $channel,
                'oldNick' => $old,
                'newNick' => $new,
            ));
            $this->modes[$connectionMask][$channel][$new] = $this->modes[$connectionMask][$channel][$old];
            unset($this->modes[$connectionMask][$channel][$old]);
        }
    }
286375
public function updateUser(User $user)
    {
        $this->find("id", $user->id);
        $this->setUserData($user);
        $this->save();
    }
1061449
public function setNewActiveContributionToSection(User $user = null)
    {
        $oldActiveContribution = $this->getActiveContribution();
        $newActiveContribution = new Contribution();
        $newActiveContribution->setSection($this);
        if (null === $oldActiveContribution) {
            if (null === $user) {
                $user = $this->getAuthor();
            }
        } else {
            if (null === $user) {
                $user = $oldActiveContribution->getContributor();
            }
            if (null === $user) {
                $user = $this->getAuthor();
            }
            $newActiveContribution->setTitle($oldActiveContribution->getTitle());
            $newActiveContribution->setText($oldActiveContribution->getText());
        }
        $newActiveContribution->setContributor($user);
        $this->setActiveContribution($newActiveContribution);
    }
536352
public static function getUserAwareChoiceBuilder(FormBuilderInterface $builder, UserInterface $user = null)
    {
        return function (EntityRepository $objectRepository) use ($builder, $user) {
            return $objectRepository->createQueryBuilder('o')
                ->andWhere('o.user = :user')
                ->setParameter('user', $user ?: $builder->getAttribute('user_aware'))
            ;
        };
    }
918983
protected function displayLoginForm(\Gems_User_Form_LoginForm $form)
    {
        $this->setCurrentOrganizationTo($form->getUser());

        $this->view->form = $form;
    }
185946
public function preUpdate(User $user, PreUpdateEventArgs $event)
    {
        if ($event->hasChangedField('avatarImage')) {
            $oldAvatarImage = $event->getOldValue('avatarImage');
            if (!empty($oldAvatarImage)) {
                $this->userService->deleteAvatar($oldAvatarImage);
            }
        }
    }