fix message for private textures

doesn't match with HTTP status code
This commit is contained in:
Pig Fang 2020-08-08 09:31:31 +08:00
parent 7e4d58d9f0
commit 76a78e187f
No known key found for this signature in database
GPG Key ID: A8198F548DADA9E2
4 changed files with 10 additions and 2 deletions

View File

@ -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'));
}
}
}

View File

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

View File

@ -11,3 +11,4 @@
- 修复重复的路由命名
- 修复私有材质的重复问题
- 修复预览图和头像不能根据图像格式来单独缓存的问题
- 修复针对私有材质的错误消息不与 HTTP 状态码相符的问题

View File

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