1d403609dSGreg Roach<?php 2d403609dSGreg Roach 3d403609dSGreg Roach/** 4d403609dSGreg Roach * webtrees: online genealogy 5*d11be702SGreg Roach * Copyright (C) 2023 webtrees development team 6d403609dSGreg Roach * This program is free software: you can redistribute it and/or modify 7d403609dSGreg Roach * it under the terms of the GNU General Public License as published by 8d403609dSGreg Roach * the Free Software Foundation, either version 3 of the License, or 9d403609dSGreg Roach * (at your option) any later version. 10d403609dSGreg Roach * This program is distributed in the hope that it will be useful, 11d403609dSGreg Roach * but WITHOUT ANY WARRANTY; without even the implied warranty of 12d403609dSGreg Roach * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13d403609dSGreg Roach * GNU General Public License for more details. 14d403609dSGreg Roach * You should have received a copy of the GNU General Public License 1589f7189bSGreg Roach * along with this program. If not, see <https://www.gnu.org/licenses/>. 16d403609dSGreg Roach */ 17fcfa147eSGreg Roach 18d403609dSGreg Roachdeclare(strict_types=1); 19d403609dSGreg Roach 20d403609dSGreg Roachnamespace Fisharebest\Webtrees\Http\RequestHandlers; 21d403609dSGreg Roach 22d403609dSGreg Roachuse Fisharebest\Webtrees\Http\ViewResponseTrait; 23d403609dSGreg Roachuse Fisharebest\Webtrees\I18N; 24a49d0e3fSGreg Roachuse Fisharebest\Webtrees\Tree; 25d403609dSGreg Roachuse Fisharebest\Webtrees\User; 26b55cbc6bSGreg Roachuse Fisharebest\Webtrees\Validator; 27d403609dSGreg Roachuse Psr\Http\Message\ResponseInterface; 28d403609dSGreg Roachuse Psr\Http\Message\ServerRequestInterface; 29d403609dSGreg Roachuse Psr\Http\Server\RequestHandlerInterface; 30d403609dSGreg Roach 31d403609dSGreg Roachuse function redirect; 32d403609dSGreg Roachuse function route; 33d403609dSGreg Roach 34d403609dSGreg Roach/** 35d403609dSGreg Roach * Request a new password. 36d403609dSGreg Roach */ 37d403609dSGreg Roachclass PasswordRequestPage implements RequestHandlerInterface 38d403609dSGreg Roach{ 39d403609dSGreg Roach use ViewResponseTrait; 40d403609dSGreg Roach 41d403609dSGreg Roach /** 42d403609dSGreg Roach * @param ServerRequestInterface $request 43d403609dSGreg Roach * 44d403609dSGreg Roach * @return ResponseInterface 45d403609dSGreg Roach */ 46d403609dSGreg Roach public function handle(ServerRequestInterface $request): ResponseInterface 47d403609dSGreg Roach { 48b55cbc6bSGreg Roach $tree = Validator::attributes($request)->treeOptional(); 49b55cbc6bSGreg Roach $user = Validator::attributes($request)->user(); 50d403609dSGreg Roach 51d403609dSGreg Roach // Already logged in? 52d403609dSGreg Roach if ($user instanceof User) { 5381bf3221SGreg Roach return redirect(route(AccountEdit::class, ['tree' => $tree?->name()])); 54d403609dSGreg Roach } 55d403609dSGreg Roach 56d403609dSGreg Roach $title = I18N::translate('Request a new password'); 57d403609dSGreg Roach 58b3a775f6SGreg Roach return $this->viewResponse('password-request-page', ['title' => $title, 'tree' => $tree]); 59d403609dSGreg Roach } 60d403609dSGreg Roach} 61