diff --git a/framework/core/src/Forum/Controller/AuthorizedClientController.php b/framework/core/src/Forum/Controller/AuthorizedClientController.php new file mode 100644 index 000000000..86dfe8b2d --- /dev/null +++ b/framework/core/src/Forum/Controller/AuthorizedClientController.php @@ -0,0 +1,30 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Flarum\Forum\Controller; + +use Flarum\Core\User; +use Psr\Http\Message\ServerRequestInterface as Request; +use Flarum\Core\Exception\PermissionDeniedException; + +class AuthorizedClientController extends ClientController +{ + /** + * {@inheritdoc} + */ + public function render(Request $request) + { + if (!$request->getAttribute('session')->get('user_id')) { + throw new PermissionDeniedException; + } + + return parent::render($request); + } +} diff --git a/framework/core/src/Forum/ForumServiceProvider.php b/framework/core/src/Forum/ForumServiceProvider.php index 8719d1963..75dafe658 100644 --- a/framework/core/src/Forum/ForumServiceProvider.php +++ b/framework/core/src/Forum/ForumServiceProvider.php @@ -80,13 +80,13 @@ class ForumServiceProvider extends AbstractServiceProvider $routes->get( '/settings', 'settings', - $toController('Flarum\Forum\Controller\ClientController') + $toController('Flarum\Forum\Controller\AuthorizedClientController') ); $routes->get( '/notifications', 'notifications', - $toController('Flarum\Forum\Controller\ClientController') + $toController('Flarum\Forum\Controller\AuthorizedClientController') ); $routes->get(