feat: Keep stored password when Enhanced App is updated
This commit is contained in:
parent
7b0ae66101
commit
54679ff9eb
1 changed files with 18 additions and 1 deletions
|
@ -180,7 +180,12 @@ class ItemController extends Controller
|
||||||
return view('items.edit', $data);
|
return view('items.edit', $data);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function storelogic($request, $id = null)
|
/**
|
||||||
|
* @param Request $request
|
||||||
|
* @param $id
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function storelogic(Request $request, $id = null)
|
||||||
{
|
{
|
||||||
$application = Application::single($request->input('appid'));
|
$application = Application::single($request->input('appid'));
|
||||||
$validatedData = $request->validate([
|
$validatedData = $request->validate([
|
||||||
|
@ -225,6 +230,18 @@ class ItemController extends Controller
|
||||||
}
|
}
|
||||||
|
|
||||||
$config = Item::checkConfig($request->input('config'));
|
$config = Item::checkConfig($request->input('config'));
|
||||||
|
|
||||||
|
// Don't overwrite the stored password if it wasn't submitted when updating the item
|
||||||
|
if ($id !== null && strpos($config, '"password":null') !== false) {
|
||||||
|
$storedItem = Item::find($id);
|
||||||
|
$storedConfigObject = json_decode($storedItem->getAttribute('description'));
|
||||||
|
|
||||||
|
$configObject = json_decode($config);
|
||||||
|
$configObject->password = $storedConfigObject->password;
|
||||||
|
|
||||||
|
$config = json_encode($configObject);
|
||||||
|
}
|
||||||
|
|
||||||
$current_user = User::currentUser();
|
$current_user = User::currentUser();
|
||||||
$request->merge([
|
$request->merge([
|
||||||
'description' => $config,
|
'description' => $config,
|
||||||
|
|
Loading…
Reference in a new issue