fix(api): apply private_key_uuid in update_server
The endpoint validated private_key_uuid but dropped it from the update, so the request silently no-op'd. Resolve the UUID to a team-scoped PrivateKey and include private_key_id in the update payload.
This commit is contained in:
parent
8a40c4e348
commit
36bf068814
1 changed files with 9 additions and 1 deletions
|
|
@ -706,7 +706,15 @@ public function update_server(Request $request)
|
|||
return response()->json(['message' => 'Invalid proxy type.'], 422);
|
||||
}
|
||||
}
|
||||
$server->update($request->only(['name', 'description', 'ip', 'port', 'user']));
|
||||
$updateFields = $request->only(['name', 'description', 'ip', 'port', 'user']);
|
||||
if ($request->filled('private_key_uuid')) {
|
||||
$privateKey = PrivateKey::whereTeamId($teamId)->whereUuid($request->private_key_uuid)->first();
|
||||
if (! $privateKey) {
|
||||
return response()->json(['message' => 'Private key not found.'], 404);
|
||||
}
|
||||
$updateFields['private_key_id'] = $privateKey->id;
|
||||
}
|
||||
$server->update($updateFields);
|
||||
if ($request->is_build_server) {
|
||||
$server->settings()->update([
|
||||
'is_build_server' => $request->is_build_server,
|
||||
|
|
|
|||
Loading…
Reference in a new issue