1
0
mirror of https://github.com/flarum/core.git synced 2025-08-02 22:47:33 +02:00

New design for reset password view

This commit is contained in:
Toby Zerner
2017-11-29 12:52:49 +10:30
parent 479e44dd04
commit 9392e1bec3
7 changed files with 213 additions and 49 deletions

View File

@@ -0,0 +1,62 @@
<?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\Http\Middleware;
use Illuminate\Support\ViewErrorBag;
use Illuminate\Contracts\View\Factory as ViewFactory;
use Psr\Http\Message\ResponseInterface as Response;
use Psr\Http\Message\ServerRequestInterface as Request;
use Zend\Stratigility\MiddlewareInterface;
/**
* Inspired by Illuminate\View\Middleware\ShareErrorsFromSession
*
* @author Taylor Otwell
*/
class ShareErrorsFromSession implements MiddlewareInterface
{
/**
* @var ViewFactory
*/
protected $view;
/**
* @param ViewFactory $view
*/
public function __construct(ViewFactory $view)
{
$this->view = $view;
}
/**
* {@inheritdoc}
*/
public function __invoke(Request $request, Response $response, callable $out = null)
{
$session = $request->getAttribute('session');
// If the current session has an "errors" variable bound to it, we will share
// its value with all view instances so the views can easily access errors
// without having to bind. An empty bag is set when there aren't errors.
$this->view->share(
'errors', $session->get('errors', new ViewErrorBag)
);
// Putting the errors in the view for every view allows the developer to just
// assume that some errors are always available, which is convenient since
// they don't have to continually run checks for the presence of errors.
$session->remove('errors');
return $out ? $out($request, $response) : $response;
}
}