1
0
mirror of https://github.com/flarum/core.git synced 2025-10-12 07:24:27 +02: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:
Franz Liedke
2017-02-03 20:25:21 +01:00
parent 9349ed13fc
commit d3753d94ae
2 changed files with 25 additions and 3 deletions

View File

@@ -12,7 +12,7 @@
namespace Flarum\Core\Listener;
use Flarum\Event\ExtensionWillBeDisabled;
use Flarum\Http\Exception\MethodNotAllowedException;
use Flarum\Http\Exception\ForbiddenException;
use Illuminate\Contracts\Events\Dispatcher;
class ExtensionValidator
@@ -27,7 +27,7 @@ class ExtensionValidator
/**
* @param ExtensionWillBeDisabled $event
* @throws MethodNotAllowedException
* @throws ForbiddenException
*/
public function whenExtensionWillBeDisabled(ExtensionWillBeDisabled $event)
{
@@ -35,7 +35,7 @@ class ExtensionValidator
$default_locale = $this->app->make('flarum.settings')->get('default_locale');
$locale = array_get($event->extension->extra, 'flarum-locale.code');
if ($locale === $default_locale) {
throw new MethodNotAllowedException('You cannot disable the default language pack!');
throw new ForbiddenException('You cannot disable the default language pack!');
}
}
}