[ANY] Laravel auth controller (#361)

This commit is contained in:
Zaxar163 2020-03-05 16:52:19 +01:00 committed by GitHub
parent c44384ccb2
commit 606eca22aa
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -12,10 +12,9 @@ class LauncherAuthController extends Controller
$data = json_decode($request->getContent()); $data = json_decode($request->getContent());
if ($data->apiKey !== env('LAUNCHER_APIKEY')) { if ($data->apiKey !== env('LAUNCHER_APIKEY')) {
$response = [ return response()->json([
'error' => 'Неверный ключ. Обратитесь к администратору', 'error' => 'Неверный ключ. Обратитесь к администратору',
]; ]);
return json_encode($response);
} }
if (Auth::attempt(['name' => $data->username, 'password' => $data->password])) { if (Auth::attempt(['name' => $data->username, 'password' => $data->password])) {
@ -24,15 +23,14 @@ class LauncherAuthController extends Controller
->where('name', '=', $data->username) ->where('name', '=', $data->username)
->first(); ->first();
$response = [ return response()->json([
'username' => $data->username, 'username' => $data->username,
'permission' => $perm->launcher_permission, 'permission' => $perm->launcher_permission,
]; ]);
} else { } else {
$response = [ return response()->json([
'error' => 'Неверный логин или пароль', 'error' => 'Неверный логин или пароль',
]; ]);
} }
return json_encode($response);
} }
} }