From 606eca22aaa27d162665a6b5428eaa9d6b89c0a3 Mon Sep 17 00:00:00 2001 From: Zaxar163 <35835496+Zaxar163@users.noreply.github.com> Date: Thu, 5 Mar 2020 16:52:19 +0100 Subject: [PATCH] [ANY] Laravel auth controller (#361) --- .../authcontroller/LauncherAuthController.php | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/compat/auth/laravel/authcontroller/LauncherAuthController.php b/compat/auth/laravel/authcontroller/LauncherAuthController.php index 5d4b2732..6c41adc4 100644 --- a/compat/auth/laravel/authcontroller/LauncherAuthController.php +++ b/compat/auth/laravel/authcontroller/LauncherAuthController.php @@ -12,10 +12,9 @@ class LauncherAuthController extends Controller $data = json_decode($request->getContent()); if ($data->apiKey !== env('LAUNCHER_APIKEY')) { - $response = [ + return response()->json([ 'error' => 'Неверный ключ. Обратитесь к администратору', - ]; - return json_encode($response); + ]); } if (Auth::attempt(['name' => $data->username, 'password' => $data->password])) { @@ -24,15 +23,14 @@ class LauncherAuthController extends Controller ->where('name', '=', $data->username) ->first(); - $response = [ + return response()->json([ 'username' => $data->username, 'permission' => $perm->launcher_permission, - ]; + ]); } else { - $response = [ + return response()->json([ 'error' => 'Неверный логин или пароль', - ]; + ]); } - return json_encode($response); } }