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