diff --git a/app/Http/Controllers/SkinlibController.php b/app/Http/Controllers/SkinlibController.php index 83c24623..3c77c40e 100644 --- a/app/Http/Controllers/SkinlibController.php +++ b/app/Http/Controllers/SkinlibController.php @@ -98,7 +98,12 @@ class SkinlibController extends Controller if (!$texture->public) { if (!Auth::check() || ($user->uid != $texture->uploader && !$user->isAdmin())) { - abort(option('status_code_for_private'), trans('skinlib.show.private')); + $statusCode = (int) option('status_code_for_private'); + if ($statusCode === 404) { + abort($statusCode, trans('skinlib.show.deleted')); + } else { + abort($statusCode, trans('skinlib.show.private')); + } } } diff --git a/resources/misc/changelogs/en/5.1.0.md b/resources/misc/changelogs/en/5.1.0.md index 403ba840..8e3a4513 100644 --- a/resources/misc/changelogs/en/5.1.0.md +++ b/resources/misc/changelogs/en/5.1.0.md @@ -11,3 +11,4 @@ - Fixed duplicated route names. - Fixed duplication of private textures. - Fixed that previews and avatars cannot be indivdually cached by image format. +- Fixed that message for private textures doesn't match with HTTP status code. diff --git a/resources/misc/changelogs/zh_CN/5.1.0.md b/resources/misc/changelogs/zh_CN/5.1.0.md index fb22dc7f..93467163 100644 --- a/resources/misc/changelogs/zh_CN/5.1.0.md +++ b/resources/misc/changelogs/zh_CN/5.1.0.md @@ -11,3 +11,4 @@ - 修复重复的路由命名 - 修复私有材质的重复问题 - 修复预览图和头像不能根据图像格式来单独缓存的问题 +- 修复针对私有材质的错误消息不与 HTTP 状态码相符的问题 diff --git a/tests/HttpTest/ControllersTest/SkinlibControllerTest.php b/tests/HttpTest/ControllersTest/SkinlibControllerTest.php index 27dbc326..e1730596 100644 --- a/tests/HttpTest/ControllersTest/SkinlibControllerTest.php +++ b/tests/HttpTest/ControllersTest/SkinlibControllerTest.php @@ -172,7 +172,8 @@ class SkinlibControllerTest extends TestCase option(['status_code_for_private' => 404]); $this->get('/skinlib/show/'.$texture->tid) ->assertNotFound() - ->assertSee(trans('skinlib.show.private')); + ->assertSee(trans('skinlib.show.deleted')); + option(['status_code_for_private' => 403]); // Other user should not see private texture $this->actingAs(factory(User::class)->create())