From d0609af143f2a519394a1e283b9aefeb7f4966a3 Mon Sep 17 00:00:00 2001 From: Haowei Wen Date: Sun, 19 May 2019 05:49:44 +0000 Subject: [PATCH] Apply fixes from StyleCI --- app/Console/Commands/RegressLikesField.php | 1 - app/Console/Kernel.php | 1 - app/Http/Controllers/AuthController.php | 4 +++- app/Http/Controllers/SkinlibController.php | 1 + app/Http/Kernel.php | 2 +- app/Http/Middleware/Authenticate.php | 1 + app/Http/Middleware/DetectLanguagePrefer.php | 3 +-- app/Http/Middleware/FireUserAuthenticated.php | 1 + app/Http/Middleware/RejectBannedUser.php | 2 ++ app/Providers/AppServiceProvider.php | 1 - app/helpers.php | 2 +- database/update_scripts/update-4.0.4-to-4.1.1.php | 2 +- routes/web.php | 2 +- tests/AuthControllerTest.php | 12 ++++++------ tests/ClosetControllerTest.php | 2 +- tests/MiddlewareTest.php | 1 + tests/PluginControllerTest.php | 2 +- tests/UserControllerTest.php | 4 ++-- 18 files changed, 24 insertions(+), 20 deletions(-) diff --git a/app/Console/Commands/RegressLikesField.php b/app/Console/Commands/RegressLikesField.php index d3a537a5..aee33e07 100644 --- a/app/Console/Commands/RegressLikesField.php +++ b/app/Console/Commands/RegressLikesField.php @@ -2,7 +2,6 @@ namespace App\Console\Commands; -use Schema; use App\Models\Texture; use Illuminate\Console\Command; diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php index 35eca8ca..cfc6ba4b 100644 --- a/app/Console/Kernel.php +++ b/app/Console/Kernel.php @@ -2,7 +2,6 @@ namespace App\Console; -use Illuminate\Console\Scheduling\Schedule; use Illuminate\Foundation\Console\Kernel as ConsoleKernel; class Kernel extends ConsoleKernel diff --git a/app/Http/Controllers/AuthController.php b/app/Http/Controllers/AuthController.php index 7744a9d6..5ac39e51 100644 --- a/app/Http/Controllers/AuthController.php +++ b/app/Http/Controllers/AuthController.php @@ -233,6 +233,7 @@ class AuthController extends Controller $user = $request->user(); $user->email = $email; $user->save(); + return redirect('/user'); } @@ -258,7 +259,7 @@ class AuthController extends Controller { $token = Auth::guard('jwt')->attempt([ 'email' => $request->email, - 'password' => $request->password + 'password' => $request->password, ]) ?: ''; return json(compact('token')); @@ -267,6 +268,7 @@ class AuthController extends Controller public function jwtLogout() { Auth::guard('jwt')->logout(); + return response('', 204); } diff --git a/app/Http/Controllers/SkinlibController.php b/app/Http/Controllers/SkinlibController.php index ec1f6a85..97d2b1cc 100644 --- a/app/Http/Controllers/SkinlibController.php +++ b/app/Http/Controllers/SkinlibController.php @@ -259,6 +259,7 @@ class SkinlibController extends Controller } $texture->delete(); + return json(trans('skinlib.delete.success'), 0); } diff --git a/app/Http/Kernel.php b/app/Http/Kernel.php index 9d276981..dd6b548e 100644 --- a/app/Http/Kernel.php +++ b/app/Http/Kernel.php @@ -32,7 +32,7 @@ class Kernel extends HttpKernel \Illuminate\Session\Middleware\StartSession::class, \Illuminate\View\Middleware\ShareErrorsFromSession::class, \App\Http\Middleware\ForbiddenIE::class, - \Illuminate\Foundation\Http\Middleware\VerifyCsrfToken::class + \Illuminate\Foundation\Http\Middleware\VerifyCsrfToken::class, ], 'api' => [ diff --git a/app/Http/Middleware/Authenticate.php b/app/Http/Middleware/Authenticate.php index 4a2ca9e9..bd01714c 100644 --- a/app/Http/Middleware/Authenticate.php +++ b/app/Http/Middleware/Authenticate.php @@ -13,6 +13,7 @@ class Authenticate extends Middleware 'last_requested_path' => $request->path(), 'msg' => trans('auth.check.anonymous'), ]); + return '/auth/login'; } } diff --git a/app/Http/Middleware/DetectLanguagePrefer.php b/app/Http/Middleware/DetectLanguagePrefer.php index 455805cb..6a652cbf 100644 --- a/app/Http/Middleware/DetectLanguagePrefer.php +++ b/app/Http/Middleware/DetectLanguagePrefer.php @@ -4,8 +4,6 @@ namespace App\Http\Middleware; use Cookie; use Illuminate\Support\Arr; -use Illuminate\Http\Request; -use Illuminate\Http\Response; class DetectLanguagePrefer { @@ -17,6 +15,7 @@ class DetectLanguagePrefer } app()->setLocale($locale); Cookie::queue('locale', $locale); + return $next($request); } } diff --git a/app/Http/Middleware/FireUserAuthenticated.php b/app/Http/Middleware/FireUserAuthenticated.php index 0e8291b2..d590e2d5 100644 --- a/app/Http/Middleware/FireUserAuthenticated.php +++ b/app/Http/Middleware/FireUserAuthenticated.php @@ -11,6 +11,7 @@ class FireUserAuthenticated if (auth()->check()) { event(new \App\Events\UserAuthenticated($request->user())); } + return $next($request); } } diff --git a/app/Http/Middleware/RejectBannedUser.php b/app/Http/Middleware/RejectBannedUser.php index 91043d01..ac97eee7 100644 --- a/app/Http/Middleware/RejectBannedUser.php +++ b/app/Http/Middleware/RejectBannedUser.php @@ -13,11 +13,13 @@ class RejectBannedUser if ($request->expectsJson()) { $response = json(trans('auth.check.banned'), -1); $response->setStatusCode(403); + return $response; } else { abort(403, trans('auth.check.banned')); } } + return $next($request); } } diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php index 51417a35..15c99c68 100644 --- a/app/Providers/AppServiceProvider.php +++ b/app/Providers/AppServiceProvider.php @@ -7,7 +7,6 @@ use Event; use App\Events; use App\Models\User; use ReflectionException; -use Illuminate\Support\Arr; use Illuminate\Support\Facades\Redis; use App\Exceptions\PrettyPageException; use Illuminate\Support\ServiceProvider; diff --git a/app/helpers.php b/app/helpers.php index 04c22d1c..1d55a6c8 100644 --- a/app/helpers.php +++ b/app/helpers.php @@ -187,7 +187,7 @@ if (! function_exists('bs_copyright')) { 'Powered by Blessing Skin Server.', 'Proudly powered by Blessing Skin Server.', '由 Blessing Skin Server 强力驱动。', - '自豪地采用 Blessing Skin Server。' + '自豪地采用 Blessing Skin Server。', ], option_localized('copyright_prefer', 0) ); diff --git a/database/update_scripts/update-4.0.4-to-4.1.1.php b/database/update_scripts/update-4.0.4-to-4.1.1.php index 6adc8a5d..b8f869b4 100644 --- a/database/update_scripts/update-4.0.4-to-4.1.1.php +++ b/database/update_scripts/update-4.0.4-to-4.1.1.php @@ -13,7 +13,7 @@ try { } catch (\Exception $e) { $tips[] = nl2br(implode("\n", [ '您需要打开终端或 PowerShell 来执行这条命令:php artisan passport:keys', - 'You need to open terminal or PowerShell and execute: php artisan passport:keys' + 'You need to open terminal or PowerShell and execute: php artisan passport:keys', ])); } diff --git a/routes/web.php b/routes/web.php index 90920b5d..e4826d16 100644 --- a/routes/web.php +++ b/routes/web.php @@ -97,7 +97,7 @@ Route::group(['prefix' => 'skinlib'], function () { Route::any('/data', 'SkinlibController@getSkinlibFiltered'); Route::group([ - 'middleware' => ['authorize', 'verified'] + 'middleware' => ['authorize', 'verified'], ], function () { Route::get('/upload', 'SkinlibController@upload'); Route::post('/upload', 'SkinlibController@handleUpload'); diff --git a/tests/AuthControllerTest.php b/tests/AuthControllerTest.php index 3d30fbf3..7d5cb267 100644 --- a/tests/AuthControllerTest.php +++ b/tests/AuthControllerTest.php @@ -551,13 +551,13 @@ class AuthControllerTest extends TestCase $this->postJson('/api/auth/login')->assertJson(['token' => false]); $token = $this->postJson('/api/auth/login', [ 'email' => $user->email, - 'password' => '12345678' + 'password' => '12345678', ])->decodeResponseJson('token'); $this->assertTrue(is_string($token)); $this->postJson('/api/auth/login', [ 'email' => $user->email, - 'password' => '123456789' + 'password' => '123456789', ])->assertJson(['token' => '']); } @@ -567,11 +567,11 @@ class AuthControllerTest extends TestCase $user->changePassword('12345678'); $token = $this->postJson('/api/auth/login', [ 'email' => $user->email, - 'password' => '12345678' + 'password' => '12345678', ])->decodeResponseJson('token'); $this->post('/api/auth/logout', [], [ - 'Authorization' => "Bearer $token" + 'Authorization' => "Bearer $token", ])->assertStatus(204); } @@ -581,11 +581,11 @@ class AuthControllerTest extends TestCase $user->changePassword('12345678'); $token = $this->postJson('/api/auth/login', [ 'email' => $user->email, - 'password' => '12345678' + 'password' => '12345678', ])->decodeResponseJson('token'); $token = $this->postJson('/api/auth/refresh', [], [ - 'Authorization' => "Bearer $token" + 'Authorization' => "Bearer $token", ])->decodeResponseJson('token'); $this->assertTrue(is_string($token)); } diff --git a/tests/ClosetControllerTest.php b/tests/ClosetControllerTest.php index b094cca8..70f14956 100644 --- a/tests/ClosetControllerTest.php +++ b/tests/ClosetControllerTest.php @@ -41,7 +41,7 @@ class ClosetControllerTest extends TestCase 'category', 'total_pages', 'items' => [['tid', 'name', 'type']], - ] + ], ]); // Responsive diff --git a/tests/MiddlewareTest.php b/tests/MiddlewareTest.php index c607b7bd..26c1595f 100644 --- a/tests/MiddlewareTest.php +++ b/tests/MiddlewareTest.php @@ -155,6 +155,7 @@ class MiddlewareTest extends TestCase $this->actingAs($user)->get('/user'); Event::assertDispatched(\App\Events\UserAuthenticated::class, function ($event) use ($user) { $this->assertEquals($user->uid, $event->user->uid); + return true; }); } diff --git a/tests/PluginControllerTest.php b/tests/PluginControllerTest.php index 8e7d59ad..dd4a7de5 100644 --- a/tests/PluginControllerTest.php +++ b/tests/PluginControllerTest.php @@ -84,7 +84,7 @@ class PluginControllerTest extends TestCase 'name' => 'whatever', ]), ], - ] + ], ]); // Enable a plugin diff --git a/tests/UserControllerTest.php b/tests/UserControllerTest.php index cd4a4ac3..cd3b9db4 100644 --- a/tests/UserControllerTest.php +++ b/tests/UserControllerTest.php @@ -27,7 +27,7 @@ class UserControllerTest extends TestCase 'email' => $user->email, 'nickname' => $user->nickname, 'score' => $user->score, - ] + ], ]); } @@ -96,7 +96,7 @@ class UserControllerTest extends TestCase 'used' => 0, ], 'remaining_time' => (int) option('sign_gap_time'), - ] + ], ]); // Remaining time is greater than 0