mirror of
https://github.com/flarum/framework.git
synced 2025-04-25 22:24:04 +08:00

Starting with version 5.9, the global funtions will be deprecated. * https://laravel-news.com/laravel-5-8-deprecates-string-and-array-helpers * https://github.com/laravel/framework/pull/26898
57 lines
1.4 KiB
PHP
57 lines
1.4 KiB
PHP
<?php
|
|
|
|
/*
|
|
* This file is part of Flarum.
|
|
*
|
|
* (c) Toby Zerner <toby.zerner@gmail.com>
|
|
*
|
|
* For the full copyright and license information, please view the LICENSE
|
|
* file that was distributed with this source code.
|
|
*/
|
|
|
|
namespace Flarum\Forum\Controller;
|
|
|
|
use DateTime;
|
|
use Flarum\Http\Controller\AbstractHtmlController;
|
|
use Flarum\User\Exception\InvalidConfirmationTokenException;
|
|
use Flarum\User\PasswordToken;
|
|
use Illuminate\Contracts\View\Factory;
|
|
use Illuminate\Support\Arr;
|
|
use Psr\Http\Message\ServerRequestInterface as Request;
|
|
|
|
class ResetPasswordController extends AbstractHtmlController
|
|
{
|
|
/**
|
|
* @var Factory
|
|
*/
|
|
protected $view;
|
|
|
|
/**
|
|
* @param Factory $view
|
|
*/
|
|
public function __construct(Factory $view)
|
|
{
|
|
$this->view = $view;
|
|
}
|
|
|
|
/**
|
|
* @param Request $request
|
|
* @return \Illuminate\Contracts\View\View
|
|
* @throws \Flarum\User\Exception\InvalidConfirmationTokenException
|
|
*/
|
|
public function render(Request $request)
|
|
{
|
|
$token = Arr::get($request->getQueryParams(), 'token');
|
|
|
|
$token = PasswordToken::findOrFail($token);
|
|
|
|
if ($token->created_at < new DateTime('-1 day')) {
|
|
throw new InvalidConfirmationTokenException;
|
|
}
|
|
|
|
return $this->view->make('flarum.forum::reset-password')
|
|
->with('passwordToken', $token->token)
|
|
->with('csrfToken', $request->getAttribute('session')->token());
|
|
}
|
|
}
|