bs-community / blessing-skin-plugins

Official plugins for Blessing Skin.
MIT License
77 stars 36 forks source link

[BUG] 尚未登陆时打开插件市场将抛出异常 #181

Closed chuanwise closed 1 year ago

chuanwise commented 1 year ago

对应 Php 代码位于 app/Http/Controllers/MarketController.php 的第 91 行附近:

if ($response->ok()) {
    return $response->json()['packages'];
} else {
    throw new Exception(trans('admin.plugins.market.connection-error', ['error' => $response->status()]));
}

当用户未登录时,$response 将是:

{"msg":{"user_not_login":"用户未登录"},"data":{"account_type":"0"},"code":1000}

因此,$response->json()['packages'] 将会抛出异常

Undefined array key "packages"
详细信息
[1] app/Http/Controllers/MarketController.php#L91
[2] app/Http/Controllers/MarketController.php#L95
[3] app/Http/Controllers/MarketController.php#L20
[4] app/Http/Middleware/CheckRole.php#L22
[5] app/Http/Middleware/FireUserAuthenticated.php#L15
[6] app/Http/Middleware/EnsureEmailFilled.php#L17
[7] app/Http/Middleware/RejectBannedUser.php#L23
[8] app/Http/Middleware/RedirectToSetup.php#L28
[9] app/Http/Middleware/EnforceEverGreen.php#L23
[10] app/Http/Middleware/DetectLanguagePrefer.php#L30
[11] app/Http/Middleware/ConvertEmptyStringsToNull.php#L23

这种尚未登陆的情况,可能来源于记住密码但很久后再打开,或者登入系统但长时间未操作。

chuanwise commented 1 year ago

参照 Discusstion 484Plugin List