mirror of
https://github.com/snipe/snipe-it.git
synced 2025-01-12 06:17:28 -08:00
Don't let a license to be checked out to a non-existent target
This commit is contained in:
parent
d2d0842737
commit
e0050bc844
|
@ -116,16 +116,20 @@ class LicenseSeatsController extends Controller
|
|||
return response()->json(Helper::formatStandardApiResponse('success', $licenseSeat, trans('admin/licenses/message.update.success')));
|
||||
}
|
||||
|
||||
// the logging functions expect only one "target". if both asset and user are present in the request,
|
||||
// we simply let assets take precedence over users...
|
||||
if ($licenseSeat->isDirty('assigned_to')) {
|
||||
$target = $is_checkin ? $oldUser : User::find($licenseSeat->assigned_to);
|
||||
}
|
||||
if ($licenseSeat->isDirty('asset_id')) {
|
||||
$target = $is_checkin ? $oldAsset : Asset::find($licenseSeat->asset_id);
|
||||
}
|
||||
|
||||
if(is_null($target)){
|
||||
return response()->json(Helper::formatStandardApiResponse('error', null, 'Target not found'));
|
||||
}
|
||||
|
||||
if ($licenseSeat->save()) {
|
||||
// the logging functions expect only one "target". if both asset and user are present in the request,
|
||||
// we simply let assets take precedence over users...
|
||||
$changes = $licenseSeat->getChanges();
|
||||
if (array_key_exists('assigned_to', $changes)) {
|
||||
$target = $is_checkin ? $oldUser : User::find($changes['assigned_to']);
|
||||
}
|
||||
if (array_key_exists('asset_id', $changes)) {
|
||||
$target = $is_checkin ? $oldAsset : Asset::find($changes['asset_id']);
|
||||
}
|
||||
|
||||
if ($is_checkin) {
|
||||
$licenseSeat->logCheckin($target, $request->input('note'));
|
||||
|
|
51
index.html
51
index.html
|
@ -1,50 +1 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>
|
||||
Snipe-IT Setup
|
||||
</title>
|
||||
|
||||
<style>
|
||||
td, th {
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.preflight-success {
|
||||
color: green;
|
||||
}
|
||||
|
||||
.preflight-error {
|
||||
color: red;
|
||||
}
|
||||
|
||||
.preflight-warning {
|
||||
color: orange;
|
||||
}
|
||||
|
||||
.page-header {
|
||||
font-size: 280%;
|
||||
}
|
||||
|
||||
h3 {
|
||||
font-size: 250%;
|
||||
}
|
||||
|
||||
.alert {
|
||||
font-size: 16px;
|
||||
}
|
||||
|
||||
</style>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="col-lg-11 col-lg-offset-1">
|
||||
<h1>D'oh. If you're seeing this, your DocumentRoot is set incorrectly. It should be set to the <code>public</code> directory.
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
{"status":"success","messages":"License updated successfully.","payload":{"id":12,"license_id":2,"assigned_to":null,"notes":null,"user_id":1,"created_at":"2022-05-25T23:04:30.000000Z","updated_at":"2022-05-26T22:07:16.000000Z","deleted_at":null,"asset_id":"1161"}}
|
Loading…
Reference in a new issue