[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());
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);
]);
}
}
}