@param ServerRequestInterface $request
@param UserInterface          $user

@return ResponseInterface
341206
public function index(ServerRequestInterface $request, UserInterface $user): ResponseInterface
    {
        $filter = $request->getQueryParams()['filter'] ?? '';

        $all_users = $this->user_service->all();

        $page_size = (int) $user->getPreference(' admin_users_page_size', '10');

        $title = I18N::translate('User administration');

        return $this->viewResponse('admin/users', [
            'all_users' => $all_users,
            'filter'    => $filter,
            'page_size' => $page_size,
            'title'     => $title,
        ]);
    }
554109
public function handle(ServerRequestInterface $request)
    {
        $userId = array_get($request->getQueryParams(), 'id');

        $testCheck = new Ip(User::find($userId));
        $testCheck->run();

        return json_encode($testCheck->getReport());
    }
1160290
public function handler(ServerRequestInterface $Request) : bool
    {
        /*
         * Request 参数
         */
        $login_name         = $Request->getPostParam($this->input_name, '');
        $login_password     = $Request->getPostParam($this->input_password, '');

        /*
         * load user
         */
        $user               = $this->UserProvider->loadByLoginName($login_name);

        /*
         * 验证
         */
        if($user == null){
            throw new UserNotExistsException('用户名或者密码错误。');
        }else if(!$user instanceof UserInterface){
            throw new NotUserInterfaceException('用户信息供给器[UserProvider]返回的值，未能实现UserInterface接口。');
        }else if($user->isEqualPassword($login_password) == false){
            throw new NotEqualPasswordException('用户名或者密码错误。');
        }

        /*
         * set session
         */
        $this->UserToken->setUser($user);

        /*
         * 触发事件
         */
        EventScheduler::instance()->on(Event::LOGIN_SUCCESS, $this->UserToken);

        /*
         * return
         */
        return true;
    }
495499
public function list(ServerRequestInterface $request, Tree $tree, UserInterface $user): ResponseInterface
    {
        $soundex_dm  = (bool) $request->get('soundex_dm');
        $soundex_std = (bool) $request->get('soundex_std');
        $surname     = $request->get('surname', '');

        // Highlight direct-line ancestors of this individual.
        $self = Individual::getInstance($tree->getUserPreference($user, 'gedcomid'), $tree);

        if ($surname !== '') {
            $individuals = $this->loadIndividuals($tree, $surname, $soundex_dm, $soundex_std);
        } else {
            $individuals = [];
        }

        if ($self !== null) {
            $ancestors = $this->allAncestors($self);
        } else {
            $ancestors = [];
        }

        // @TODO - convert this to use views
        $html = view('branches-list', [
            'branches' => $this->getPatriarchsHtml($tree, $individuals, $ancestors, $surname, $soundex_dm, $soundex_std),
        ]);

        return response($html);
    }
959809
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
    {
        $context = RequestBootstrap::getInternalRequestContext();
        if (empty($context) || empty($context->getBackendUserId())) {
            return $handler->handle($request);
        }

        $backendUser = $this->createBackendUser();
        $backendUser->user = GeneralUtility::makeInstance(ConnectionPool::class)
            ->getConnectionForTable('be_users')
            ->select(['*'], 'be_users', ['uid' => $context->getBackendUserId()])
            ->fetch();
        if (!empty($context->getWorkspaceId())) {
            $backendUser->setTemporaryWorkspace($context->getWorkspaceId());
        }

        $GLOBALS['BE_USER'] = $backendUser;
        $this->setBackendUserAspect(GeneralUtility::makeInstance(Context::class), $backendUser);
        return $handler->handle($request);
    }
1093582
public function create(UserInterface $user) {
    $this->tokens->purge($user);
    return $this->tokens->create($user);
  }
1271813
protected function loadUserThrottles(UserInterface $user)
    {
        $queryBuilder = $this->getEntityManager()->createQueryBuilder();
        $queryBuilder
            ->select('t')
            ->from($this->entityName('user'), 't')
            ->where('t.createdAt > :interval')
            ->andWhere('t.user = :user')
            ->setParameters([
                'interval' => Carbon::now()->subSeconds($this->userInterval),
                'user'     => $user
            ]);

        return new Collection($queryBuilder->getQuery()->getResult());
    }
875098
protected function login(Request $request, User $user)
    {
        impersonate()->login($user);

        // if redirect url in request
        if ($request->has('redirect_to')) {
            return redirect($request->get('redirect_to'));
        }

        return back();
    }
673121
public function verify(ServerRequestInterface $request, Tree $tree, UserService $user_service): ResponseInterface
    {
        $username = $request->get('username', '');
        $token    = $request->get('token', '');

        $title = I18N::translate('User verification');

        $user = $user_service->findByUserName($username);

        if ($user instanceof User && $user->getPreference('reg_hashcode') === $token) {
            // switch language to webmaster settings
            $webmaster = $user_service->find((int) $tree->getPreference('WEBMASTER_USER_ID'));

            if ($webmaster instanceof User) {
                I18N::init($webmaster->getPreference('language'));

                /* I18N: %s is a server name/URL */
                $subject = I18N::translate('New user at %s', WT_BASE_URL . ' ' . $tree->title());

                Mail::send(
                    new TreeUser($tree),
                    $webmaster,
                    new TreeUser($tree),
                    $subject,
                    view('emails/verify-notify-text', ['user' => $user]),
                    view('emails/verify-notify-html', ['user' => $user])
                );

                $mail1_method = $webmaster->getPreference('CONTACT_METHOD');

                if ($mail1_method !== 'messaging3' && $mail1_method !== 'mailto' && $mail1_method !== 'none') {
                    DB::table('message')->insert([
                        'sender'     => $username,
                        'ip_address' => $request->getClientIp(),
                        'user_id'    => $webmaster->id(),
                        'subject'    => $subject,
                        'body'       => view('emails/verify-notify-text', ['user' => $user]),
                    ]);
                }
                I18N::init(WT_LOCALE);
            }

            $user
                ->setPreference('verified', '1')
                ->setPreference('reg_timestamp', date('U'))
                ->setPreference('reg_hashcode', '');

            Log::addAuthenticationLog('User ' . $username . ' verified their email address');

            return $this->viewResponse('verify-success-page', [
                'title' => $title,
            ]);
        }

        return $this->viewResponse('verify-failure-page', [
            'title' => $title,
        ]);
    }
516071
public function individualList(ServerRequestInterface $request, Tree $tree, UserInterface $user, ?ModuleListInterface $moduleListInterface): ResponseInterface
    {
        return $this->individualOrFamilyList($request, $tree, $user, false, $moduleListInterface);
    }
424596
public function treePageBlockEdit(ServerRequestInterface $request, Tree $tree, UserInterface $user): ResponseInterface
    {
        $block_id = (int) $request->get('block_id');
        $block    = $this->treeBlock($request, $tree, $user);
        $title    = $block->title() . ' — ' . I18N::translate('Preferences');

        return $this->viewResponse('modules/edit-block-config', [
            'block'      => $block,
            'block_id'   => $block_id,
            'cancel_url' => route('tree-page', ['ged' => $tree->name()]),
            'title'      => $title,
            'tree'       => $tree,
        ]);
    }
671139
public function userPageUserEdit(ServerRequestInterface $request): ResponseInterface
    {
        $user_id     = (int) $request->get('user_id');
        $user        = $this->user_service->find($user_id);
        $main_blocks = $this->userBlocks($user->id(), 'main');
        $side_blocks = $this->userBlocks($user->id(), 'side');
        $all_blocks  = $this->availableUserBlocks();
        $title       = I18N::translate('Change the blocks on this user’s “My page”') . ' - ' . e($user->userName());
        $url_cancel  = route('admin-users');
        $url_save    = route('user-page-user-update', ['user_id' => $user_id]);

        return $this->viewResponse('edit-blocks-page', [
            'all_blocks'  => $all_blocks,
            'can_reset'   => false,
            'main_blocks' => $main_blocks,
            'side_blocks' => $side_blocks,
            'title'       => $title,
            'url_cancel'  => $url_cancel,
            'url_save'    => $url_save,
        ]);
    }
732102
public function handle(ServerRequestInterface $request): ResponseInterface
    {
        $stack = new Stack(
            $this->handlers,
            $this->handlerResolver
        );
        return $stack->handle($request);
    }
1371725
public function handle(ServerRequestInterface $request): ResponseInterface
    {
        $user_id = (int) $request->getParsedBody()['user_id'];

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

        if ($user === null) {
            throw new NotFoundHttpException('User ID ' . $user_id . ' not found');
        }

        if (Auth::isAdmin($user)) {
            throw new AccessDeniedHttpException('Cannot delete an administrator');
        }

        Log::addAuthenticationLog('Deleted user: ' . $user->userName());
        $this->user_service->delete($user);

        return response('', StatusCodeInterface::STATUS_NO_CONTENT);
    }
1166865
public function getChartAction(ServerRequestInterface $request, Tree $tree, UserInterface $user): ResponseInterface
    {
        Auth::checkComponentAccess($this, 'chart', $tree, $user);

        $ajax      = (bool) $request->get('ajax');
        $xrefs     = (array) $request->get('xrefs', []);
        $addxref   = $request->get('addxref', '');
        $addfam    = (bool) $request->get('addfam', false);
        $placename = $request->get('placename', '');
        $start     = $request->get('start', '');
        $end       = $request->get('end', '');

        $place      = new Place($placename, $tree);
        $start_date = new Date($start);
        $end_date   = new Date($end);

        $xrefs = array_unique($xrefs);

        // Add an individual, and family members
        $individual = Individual::getInstance($addxref, $tree);
        if ($individual !== null) {
            $xrefs[] = $addxref;
            if ($addfam) {
                $xrefs = array_merge($xrefs, $this->closeFamily($individual));
            }
        }

        // Select by date and/or place.
        if ($start_date->isOK() && $end_date->isOK() && $placename !== '') {
            $date_xrefs  = $this->findIndividualsByDate($start_date, $end_date, $tree);
            $place_xrefs = $this->findIndividualsByPlace($place, $tree);
            $xrefs       = array_intersect($date_xrefs, $place_xrefs);
        } elseif ($start_date->isOK() && $end_date->isOK()) {
            $xrefs = $this->findIndividualsByDate($start_date, $end_date, $tree);
        } elseif ($placename !== '') {
            $xrefs = $this->findIndividualsByPlace($place, $tree);
        }

        // Filter duplicates and private individuals.
        $xrefs = array_unique($xrefs);
        $xrefs = array_filter($xrefs, static function (string $xref) use ($tree): bool {
            $individual = Individual::getInstance($xref, $tree);

            return $individual !== null && $individual->canShow();
        });

        if ($ajax) {
            $subtitle = $this->subtitle(count($xrefs), $start_date, $end_date, $placename);

            return $this->chart($tree, $xrefs, $subtitle);
        }

        $ajax_url = route('module', [
            'ajax'   => true,
            'module' => $this->name(),
            'action' => 'Chart',
            'ged'    => $tree->name(),
            'xrefs'  => $xrefs,
        ]);

        $reset_url = route('module', [
            'module' => $this->name(),
            'action' => 'Chart',
            'ged'    => $tree->name(),
        ]);

        return $this->viewResponse('modules/lifespans-chart/page', [
            'ajax_url'    => $ajax_url,
            'module_name' => $this->name(),
            'reset_url'   => $reset_url,
            'title'       => $this->title(),
            'xrefs'       => $xrefs,
        ]);
    }
179464
public function broadcastAction(ServerRequestInterface $request, Tree $tree, UserInterface $user): ResponseInterface
    {
        $body    = $request->get('body', '');
        $subject = $request->get('subject', '');
        $to      = $request->get('to', '');
        $url     = $request->get('url', '');

        $ip       = $request->getClientIp() ?? '127.0.0.1';
        $to_users = $this->recipientUsers($to);

        if ($body === '' || $subject === '') {
            return redirect(route('broadcast', [
                'body'    => $body,
                'subject' => $subject,
                'to'      => $to,
                'tree'    => $tree,
                'url'     => $url,
            ]));
        }

        $errors = false;

        foreach ($to_users as $to_user) {
            if ($this->deliverMessage($tree, $user, $to_user, $subject, $body, $url, $ip)) {
                FlashMessages::addMessage(I18N::translate('The message was successfully sent to %s.', e($to_user->realName())), 'success');
            } else {
                $errors = true;
            }
        }

        if ($errors) {
            FlashMessages::addMessage(I18N::translate('The message was not sent.'), 'danger');
        }

        return redirect(route('admin-control-panel'));
    }
130291
public function postAuthProcess(Request $request, User $user)
    {
        $date = new \DateTime('+' . (int) $this->getConf()->get(['registry', 'actions', 'validation-reminder-days']) . ' days');
        $manager = $this->getEntityManager();

        foreach ($this->getValidationParticipantRepository()->findNotConfirmedAndNotRemindedParticipantsByExpireDate($date) as $participant) {
            $validationSession = $participant->getSession();
            $basket = $validationSession->getBasket();

            if (null === $token = $this->getTokenRepository()->findValidationToken($basket, $participant->getUser())) {
                continue;
            }

            $url = $this->app->url('lightbox_validation', ['basket' => $basket->getId(), 'LOG' => $token->getValue()]);
            $this->dispatch(PhraseaEvents::VALIDATION_REMINDER, new ValidationEvent($participant, $basket, $url));

            $participant->setReminded(new \DateTime('now'));
            $manager->persist($participant);
        }

        $manager->flush();

        $session = $this->getAuthenticator()->openAccount($user);

        if ($user->getLocale() != $this->app['locale']) {
            $user->setLocale($this->app['locale']);
        }

        $width = $height = null;
        if ($request->cookies->has('screen')) {
            $data = array_filter((explode('x', $request->cookies->get('screen', ''))));
            if (count($data) === 2) {
                $width = $data[0];
                $height = $data[1];
            }
        }
        $session->setIpAddress($request->getClientIp())
            ->setScreenHeight($height)
            ->setScreenWidth($width);

        $manager->persist($session);
        $manager->flush();

        return $session;
    }