401 for unauthorised request to settings, notifications page fixes #714

This commit is contained in:
Sajjad Hasehmian 2016-02-10 14:22:41 +03:30
parent e3f6092c32
commit 28ed01ffcc
2 changed files with 32 additions and 2 deletions

View File

@ -0,0 +1,30 @@
<?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 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);
}
}

View File

@ -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(