mirror of
https://github.com/flarum/framework.git
synced 2025-02-02 17:15:00 +08:00
Throw HTTP 403 on extension validation error
The way I read it, HTTP 405 is a generic statement about the resource. Once a language pack is not the default, this is not true anymore, so I figured 403 is more correct.
This commit is contained in:
parent
8ff3a05541
commit
3b97eaa658
|
@ -12,7 +12,7 @@
|
||||||
namespace Flarum\Core\Listener;
|
namespace Flarum\Core\Listener;
|
||||||
|
|
||||||
use Flarum\Event\ExtensionWillBeDisabled;
|
use Flarum\Event\ExtensionWillBeDisabled;
|
||||||
use Flarum\Http\Exception\MethodNotAllowedException;
|
use Flarum\Http\Exception\ForbiddenException;
|
||||||
use Illuminate\Contracts\Events\Dispatcher;
|
use Illuminate\Contracts\Events\Dispatcher;
|
||||||
|
|
||||||
class ExtensionValidator
|
class ExtensionValidator
|
||||||
|
@ -27,7 +27,7 @@ class ExtensionValidator
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param ExtensionWillBeDisabled $event
|
* @param ExtensionWillBeDisabled $event
|
||||||
* @throws MethodNotAllowedException
|
* @throws ForbiddenException
|
||||||
*/
|
*/
|
||||||
public function whenExtensionWillBeDisabled(ExtensionWillBeDisabled $event)
|
public function whenExtensionWillBeDisabled(ExtensionWillBeDisabled $event)
|
||||||
{
|
{
|
||||||
|
@ -35,7 +35,7 @@ class ExtensionValidator
|
||||||
$default_locale = $this->app->make('flarum.settings')->get('default_locale');
|
$default_locale = $this->app->make('flarum.settings')->get('default_locale');
|
||||||
$locale = array_get($event->extension->extra, 'flarum-locale.code');
|
$locale = array_get($event->extension->extra, 'flarum-locale.code');
|
||||||
if ($locale === $default_locale) {
|
if ($locale === $default_locale) {
|
||||||
throw new MethodNotAllowedException('You cannot disable the default language pack!');
|
throw new ForbiddenException('You cannot disable the default language pack!');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
22
framework/core/src/Http/Exception/ForbiddenException.php
Normal file
22
framework/core/src/Http/Exception/ForbiddenException.php
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
<?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\Exception;
|
||||||
|
|
||||||
|
use Exception;
|
||||||
|
|
||||||
|
class ForbiddenException extends Exception
|
||||||
|
{
|
||||||
|
public function __construct($message = null, $code = 403, Exception $previous = null)
|
||||||
|
{
|
||||||
|
parent::__construct($message, $code, $previous);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user