update
This commit is contained in:
@@ -7,6 +7,7 @@ use App\Repositories\DnsManager\Server\DnsServerRepositoryInterface;
|
||||
use App\Services\ServerService;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Crypt;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class ServerController extends Controller
|
||||
@@ -82,7 +83,7 @@ class ServerController extends Controller
|
||||
'name' => $validated['name'],
|
||||
'ip_address' => $validated['ip_address'],
|
||||
'username' => $validated['username'],
|
||||
'password' => encrypt($validated['password']),
|
||||
'password' => Crypt::encryptString($validated['password']),
|
||||
'api_key' => $validated['api_key'] ?? null,
|
||||
'status' => $validated['status'] ?? 'activated',
|
||||
]);
|
||||
@@ -125,7 +126,7 @@ class ServerController extends Controller
|
||||
->toArray();
|
||||
|
||||
if ($request->filled('password')) {
|
||||
$payload['password'] = encrypt((string) $request->password);
|
||||
$payload['password'] = Crypt::encryptString((string) $request->password);
|
||||
}
|
||||
|
||||
$this->serverRepository->update($id, $payload);
|
||||
@@ -161,12 +162,12 @@ class ServerController extends Controller
|
||||
return response()->json(['error' => true, 'message' => "Không tìm thấy server #$id"], 404);
|
||||
}
|
||||
|
||||
$connected = $this->serverService->checkConnectionByServer($server);
|
||||
$meta = $this->serverService->checkConnectionByServer($server);
|
||||
|
||||
return response()->json([
|
||||
'error' => !$connected,
|
||||
'data' => ['connected' => $connected],
|
||||
'message' => $connected
|
||||
'error' => $meta === false,
|
||||
'data' => ['connected' => $meta !== false, 'server' => $meta ?: null],
|
||||
'message' => $meta !== false
|
||||
? 'Kết nối server thành công.'
|
||||
: 'Không thể kết nối tới server. Vui lòng kiểm tra lại IP hoặc tài khoản.',
|
||||
]);
|
||||
|
||||
Reference in New Issue
Block a user