Compare commits

...

24 Commits

Author SHA1 Message Date
snipe
a3e35e0c99 Added form request
Signed-off-by: snipe <snipe@snipe.net>
2025-06-25 16:29:42 +01:00
snipe
2e8c51be9c First steps for #16883 - bulk asset auduting via API
Signed-off-by: snipe <snipe@snipe.net>
2025-05-09 11:35:30 +01:00
snipe
7d9b87f059 Merge pull request #16898 from marcusmoore/chore/form-radio-replacement
Replaced Form::radio helpers
2025-05-08 20:50:29 +01:00
Marcus Moore
c157f4190e Replace Form::radio in location partial 2025-05-08 12:25:48 -07:00
Marcus Moore
9357eca1cd Replace Form::radio on asset checkin page 2025-05-08 12:16:55 -07:00
snipe
40c65a07a4 Merge pull request #16896 from grokability/removed_seat_number
Removed seat "name" from licenses seats API/UI response
2025-05-08 17:57:40 +01:00
snipe
13521bcf75 Removed seat “name” from license seats API/UI
Signed-off-by: snipe <snipe@snipe.net>
2025-05-08 17:37:27 +01:00
snipe
1c09dc139a Undo previous change
Signed-off-by: snipe <snipe@snipe.net>
2025-05-08 16:40:24 +01:00
snipe
d5f955b1e0 License seats are not numbered correctly [sc-29113]
Signed-off-by: snipe <snipe@snipe.net>
2025-05-08 16:25:49 +01:00
snipe
9e6e8f0931 Moved incomplete test marker
Signed-off-by: snipe <snipe@snipe.net>
2025-05-08 16:22:09 +01:00
snipe
c93ef30801 Ignore flaky test
Signed-off-by: snipe <snipe@snipe.net>
2025-05-08 15:43:40 +01:00
snipe
3e0dec4856 Fixed #16893 - more specific upload failure text
Signed-off-by: snipe <snipe@snipe.net>
2025-05-08 15:38:38 +01:00
snipe
0b167f5f6f Grab location uploads from backup
Signed-off-by: snipe <snipe@snipe.net>
2025-05-08 15:22:26 +01:00
snipe
f6b21fdb82 Merge pull request #16895 from grokability/fixed_#16863_custom_fields_validation
Fixed #16863 - better handle custom fields validation when unique but not required
2025-05-08 15:09:04 +01:00
snipe
f151628808 Merge pull request #16894 from grokability/resolve-webserver-permissions
Fix webserver/user file permissions issue
2025-05-08 15:08:40 +01:00
snipe
e44aad0328 Fixed typeos 2025-05-08 15:08:14 +01:00
snipe
1881054c92 Fixed #16863 - better handle unique not required custom field redirects
Signed-off-by: snipe <snipe@snipe.net>
2025-05-08 15:00:43 +01:00
Jeremy Price
f7533c5e41 Fix webserver/user file permissions issue
Fixes https://github.com/grokability/snipe-it/issues/16777

We weren't adding the webserver user to the app-user's group, which was
a problem for the webserver trying to write to the log file if it had
been created by a user-owned process (like a cron) or the installation
script chown-ing everything... even though the log file was created 664

This would often present in mysterious ways. In the linked case, trying
to upload a cvs for import would fail with an unhelpful message, because
the actual error is swallowed in the generic error handler for the page.

I've filed an issue to hopefully help with that: https://github.com/grokability/snipe-it/issues/16893

Used this opportunity to condense some logic that was
identical between architectures,
2025-05-08 13:55:23 +02:00
snipe
f181e0fa55 Merge pull request #16877 from marcusmoore/bug/sc-29012
Allow updating asset model image via api
2025-05-08 06:27:49 +01:00
snipe
b04efdfefc Merge pull request #16889 from grokability/add_updated_range_to_custom_report
Added #16887 - last updated date range for custom report
2025-05-08 06:27:32 +01:00
snipe
352b935dee Merge pull request #16884 from marcusmoore/bug/sc-29097
Removed `2fa_authed` from session upon logout
2025-05-08 06:23:26 +01:00
snipe
0ba3b9975a Added #16887 - last updated date range for custom report
Signed-off-by: snipe <snipe@snipe.net>
2025-05-08 06:21:06 +01:00
Marcus Moore
cc06187f31 Remove 2fa_authed from session upon logout 2025-05-07 14:04:33 -07:00
Marcus Moore
d75de73867 Allow updating asset model image via api 2025-05-06 17:13:23 -07:00
21 changed files with 185 additions and 69 deletions

View File

@@ -249,6 +249,7 @@ class RestoreFromBackup extends Command
'storage/private_uploads/consumables',
'storage/private_uploads/eula-pdfs',
'storage/private_uploads/imports',
'storage/private_uploads/locations',
'storage/private_uploads/licenses',
'storage/private_uploads/signatures',
'storage/private_uploads/users',

View File

@@ -35,6 +35,7 @@ use Illuminate\Support\Facades\Route;
use App\View\Label;
use Illuminate\Support\Facades\Storage;
use Illuminate\Support\Facades\Validator;
use App\Http\Requests\AuditRequest;
/**
@@ -1071,25 +1072,33 @@ class AssetsController extends Controller
* @param int $id
* @since [v4.0]
*/
public function audit(Request $request, Asset $asset): JsonResponse
public function audit(AuditRequest $request): JsonResponse
{
$this->authorize('audit', Asset::class);
$settings = Setting::getSettings();
$dt = Carbon::now()->addMonths($settings->audit_interval)->toDateString();
// Allow the asset tag to be passed in the payload (legacy method)
if ($request->filled('asset_tag')) {
$asset = Asset::where('asset_tag', '=', $request->input('asset_tag'))->first();
// Check if it's an array or a string
if (is_array($request->input('asset_tag'))) {
$asset_tag = $request->input('asset_tag');
$multi_audit = true;
} else {
// If it's a string, make it into an array so we can use it in the whereIn query
$asset_tag = [$request->input('asset_tag')];
$multi_audit = false;
}
if ($asset) {
$assets = Asset::whereIn('asset_tag', $asset_tag)->get();
foreach ($assets as $asset) {
$originalValues = $asset->getRawOriginal();
$asset->next_audit_date = $dt;
$asset->last_audit_date = date('Y-m-d H:i:s');
// Overwrite next_audit_date if it was specified in the request
if ($request->filled('next_audit_date')) {
$asset->next_audit_date = $request->input('next_audit_date');
}
@@ -1100,15 +1109,24 @@ class AssetsController extends Controller
$asset->location_id = $request->input('location_id');
}
$asset->last_audit_date = date('Y-m-d H:i:s');
// Set up the payload for re-display in the API response
$payload = [
'id' => $asset->id,
'asset_tag' => $asset->asset_tag,
'note' => $request->input('note'),
'next_audit_date' => Helper::getFormattedDateObject($asset->next_audit_date),
];
if ($multi_audit === true) {
$payload[] = [
'id' => $asset->id,
'asset_tag' => $asset->asset_tag,
'note' => $request->input('note'),
'next_audit_date' => Helper::getFormattedDateObject($asset->next_audit_date),
];
} else {
$payload[] = [
'id' => $asset->id,
'asset_tag' => $asset->asset_tag,
'note' => $request->input('note'),
'next_audit_date' => Helper::getFormattedDateObject($asset->next_audit_date),
];
}
/**
@@ -1176,11 +1194,14 @@ class AssetsController extends Controller
*/
if ($asset->isValid() && $asset->save()) {
$asset->logAudit(request('note'), request('location_id'), null, $originalValues);
return response()->json(Helper::formatStandardApiResponse('success', $payload, trans('admin/hardware/message.audit.success')));
}
}
if (count($payload) > 0) {
return response()->json(Helper::formatStandardApiResponse('success', $payload, trans('admin/hardware/message.audit.success')));
}
// No matching asset for the asset tag that was passed.
return response()->json(Helper::formatStandardApiResponse('error', null, trans('admin/hardware/message.does_not_exist')), 200);

View File

@@ -34,7 +34,7 @@ class LicenseSeatsController extends Controller
if ($request->input('sort') == 'department') {
$seats->OrderDepartments($order);
} else {
$seats->orderBy('id', $order);
$seats->orderBy('updated_at', $order);
}
$total = $seats->count();

View File

@@ -42,12 +42,11 @@ class AssetCheckinController extends Controller
return redirect()->route('hardware.show', $asset->id)->with('error', trans('admin/hardware/general.model_invalid_fix'));
}
// Validate custom fields on existing asset
$validator = Validator::make($asset->toArray(), $asset->customFieldValidationRules());
// Invoke the validation to see if the audit will complete successfully
$asset->setRules($asset->getRules() + $asset->customFieldValidationRules());
if ($validator->fails()) {
return redirect()->route('hardware.edit', $asset)
->withErrors($validator);
if ($asset->isInvalid()) {
return redirect()->route('hardware.edit', $asset)->withErrors($asset->getErrors());
}
$target_option = match ($asset->assigned_type) {

View File

@@ -37,13 +37,13 @@ class AssetCheckoutController extends Controller
->with('error', trans('admin/hardware/general.model_invalid_fix'));
}
// Validate custom fields on existing asset
$validator = Validator::make($asset->toArray(), $asset->customFieldValidationRules());
// Invoke the validation to see if the audit will complete successfully
$asset->setRules($asset->getRules() + $asset->customFieldValidationRules());
if ($validator->fails()) {
return redirect()->route('hardware.edit', $asset)
->withErrors($validator);
if ($asset->isInvalid()) {
return redirect()->route('hardware.edit', $asset)->withErrors($asset->getErrors());
}
if ($asset->availableForCheckout()) {
return view('hardware/checkout', compact('asset'))

View File

@@ -882,12 +882,12 @@ class AssetsController extends Controller
$this->authorize('audit', Asset::class);
$settings = Setting::getSettings();
// Validate custom fields on existing asset
$validator = Validator::make($asset->toArray(), $asset->customFieldValidationRules());
if ($validator->fails()) {
return redirect()->route('hardware.edit', $asset)
->withErrors($validator);
// Invoke the validation to see if the audit will complete successfully
$asset->setRules($asset->getRules() + $asset->customFieldValidationRules());
if ($asset->isInvalid()) {
return redirect()->route('hardware.edit', $asset)->withErrors($asset->getErrors());
}
$dt = Carbon::now()->addMonths($settings->audit_interval)->toDateString();

View File

@@ -484,6 +484,7 @@ class LoginController extends Controller
}
$request->session()->regenerate(true);
$request->session()->forget('2fa_authed');
if ($request->session()->has('password_hash_'.Auth::getDefaultDriver())){
$request->session()->remove('password_hash_'.Auth::getDefaultDriver());

View File

@@ -737,6 +737,11 @@ class ReportsController extends Controller
if (($request->filled('next_audit_start')) && ($request->filled('next_audit_end'))) {
$assets->whereBetween('assets.next_audit_date', [$request->input('next_audit_start'), $request->input('next_audit_end')]);
}
if (($request->filled('last_updated_start')) && ($request->filled('last_updated_end'))) {
$assets->whereBetween('assets.updated_at', [$request->input('last_updated_start'), $request->input('last_updated_end')]);
}
if ($request->filled('exclude_archived')) {
$assets->notArchived();
}

View File

@@ -0,0 +1,30 @@
<?php
namespace App\Http\Requests;
use App\Models\Asset;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Support\Facades\Gate;
class AuditRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*/
public function authorize(): bool
{
return Gate::allows('audit', new Asset);
}
/**
* Get the validation rules that apply to the request.
*
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
*/
public function rules(): array
{
return [
'asset_tag' => 'required|exists:assets,asset_tag',
];
}
}

View File

@@ -19,6 +19,7 @@ class StoreAssetModelRequest extends ImageUploadRequest
public function prepareForValidation(): void
{
parent::prepareForValidation();
if ($this->category_id) {
if ($category = Category::find($this->category_id)) {

View File

@@ -13,16 +13,15 @@ class LicenseSeatsTransformer
public function transformLicenseSeats(Collection $seats, $total)
{
$array = [];
$seat_count = 0;
foreach ($seats as $seat) {
$seat_count++;
$array[] = self::transformLicenseSeat($seat, $seat_count);
$array[] = self::transformLicenseSeat($seat);
}
return (new DatatablesTransformer)->transformDatatables($array, $total);
}
public function transformLicenseSeat(LicenseSeat $seat, $seat_count = 0)
public function transformLicenseSeat(LicenseSeat $seat)
{
$array = [
'id' => (int) $seat->id,
@@ -55,10 +54,6 @@ class LicenseSeatsTransformer
'user_can_checkout' => (($seat->assigned_to == '') && ($seat->asset_id == '')),
];
if ($seat_count != 0) {
$array['name'] = trans('admin/licenses/general.seat_count', ['count' => $seat_count]);
}
$permissions_array['available_actions'] = [
'checkout' => Gate::allows('checkout', License::class),
'checkin' => Gate::allows('checkin', License::class),

View File

@@ -113,7 +113,10 @@ class CustomFieldset extends Model
$rule[] = 'unique_undeleted';
}
array_push($rule, $field->attributes['format']);
if ($field->attributes['format']!='') {
array_push($rule, $field->attributes['format']);
}
$rules[$field->db_column_name()] = $rule;

View File

@@ -230,16 +230,7 @@ class LicensePresenter extends Presenter
'switchable' => true,
'title' => trans('general.id'),
'visible' => false,
],
[
'field' => 'name',
'searchable' => false,
'sortable' => false,
'sorter' => 'numericOnly',
'switchable' => true,
'title' => trans('admin/licenses/general.seat'),
'visible' => true,
], [
],[
'field' => 'assigned_user',
'searchable' => false,
'sortable' => false,
@@ -285,7 +276,7 @@ class LicensePresenter extends Presenter
'searchable' => false,
'sortable' => true,
'visible' => false,
'title' => trans('general.date'),
'title' => trans('general.updated_at'),
'formatter' => 'dateDisplayFormatter',
],
[

View File

@@ -522,7 +522,7 @@ return [
'checked_out_to_fields' => 'Checked Out To Fields',
'percent_complete' => '% complete',
'uploading' => 'Uploading... ',
'upload_error' => 'Error uploading file. Please check that there are no empty rows and that no column names are duplicated.',
'upload_error' => 'Error uploading file. Please check that you have no empty rows or duplicated column names in your CSV, and that the server permissions allow uploads.',
'copy_to_clipboard' => 'Copy to Clipboard',
'copied' => 'Copied!',
'status_compatibility' => 'If assets are already assigned, they cannot be changed to a non-deployable status type and this value change will be skipped.',

View File

@@ -106,11 +106,11 @@
<div class="form-group">
<div class="col-md-9 col-md-offset-3">
<label class="form-control">
{{ Form::radio('update_default_location', '1', old('update_default_location'), ['checked'=> 'checked', 'aria-label'=>'update_default_location']) }}
<input name="update_default_location" type="radio" value="1" checked="checked" aria-label="update_default_location" />
{{ trans('admin/hardware/form.asset_location') }}
</label>
<label class="form-control">
{{ Form::radio('update_default_location', '0', old('update_default_location'), ['aria-label'=>'update_default_location']) }}
<input name="update_default_location" type="radio" value="0" aria-label="update_default_location" />
{{ trans('admin/hardware/form.asset_location_update_default_current') }}
</label>
</div>

View File

@@ -40,11 +40,11 @@
<div class="form-group">
<div class="col-md-9 col-md-offset-3">
<label class="form-control">
{{ Form::radio('update_default_location', '1', old('update_default_location'), ['checked'=> 'checked', 'aria-label'=>'update_default_location']) }}
<input name="update_default_location" type="radio" value="1" checked="checked" aria-label="update_default_location" />
{{ trans('admin/hardware/form.asset_location') }}
</label>
<label class="form-control">
{{ Form::radio('update_default_location', '0', old('update_default_location'), ['aria-label'=>'update_default_location']) }}
<input name="update_default_location" type="radio" value="0" aria-label="update_default_location" />
{{ trans('admin/hardware/form.asset_location_update_default_current') }}
</label>
</div>

View File

@@ -411,7 +411,7 @@
<!-- Purchase Date -->
<div class="form-group purchase-range{{ ($errors->has('purchase_start') || $errors->has('purchase_end')) ? ' has-error' : '' }}">
<label for="purchase_start" class="col-md-3 control-label">{{ trans('general.purchase_date') }}</label>
<div class="input-daterange input-group col-md-7" id="datepicker">
<div class="input-daterange input-group col-md-7" id="purchase-range-datepicker">
<input type="text" class="form-control" name="purchase_start" aria-label="purchase_start" value="{{ $template->textValue('purchase_start', old('purchase_start')) }}">
<span class="input-group-addon">{{ strtolower(trans('general.to')) }}</span>
<input type="text" class="form-control" name="purchase_end" aria-label="purchase_end" value="{{ $template->textValue('purchase_end', old('purchase_end')) }}">
@@ -427,9 +427,9 @@
</div>
<!-- Created Date -->
<div class="form-group purchase-range{{ ($errors->has('created_start') || $errors->has('created_end')) ? ' has-error' : '' }}">
<div class="form-group created-range{{ ($errors->has('created_start') || $errors->has('created_end')) ? ' has-error' : '' }}">
<label for="created_start" class="col-md-3 control-label">{{ trans('general.created_at') }} </label>
<div class="input-daterange input-group col-md-7" id="datepicker">
<div class="input-daterange input-group col-md-7" id="created-range-datepicker">
<input type="text" class="form-control" name="created_start" aria-label="created_start" value="{{ $template->textValue('created_start', old('created_start')) }}">
<span class="input-group-addon">{{ strtolower(trans('general.to')) }}</span>
<input type="text" class="form-control" name="created_end" aria-label="created_end" value="{{ $template->textValue('created_end', old('created_end')) }}">
@@ -446,7 +446,7 @@
<!-- Checkout Date -->
<div class="form-group checkout-range{{ ($errors->has('checkout_date_start') || $errors->has('checkout_date_end')) ? ' has-error' : '' }}">
<label for="checkout_date" class="col-md-3 control-label">{{ trans('general.checkout') }} </label>
<div class="input-daterange input-group col-md-7" id="datepicker">
<div class="input-daterange input-group col-md-7" id="checkout-range-datepicker">
<input type="text" class="form-control" name="checkout_date_start" aria-label="checkout_date_start" value="{{ $template->textValue('checkout_date_start', old('checkout_date_start')) }}">
<span class="input-group-addon">{{ strtolower(trans('general.to')) }}</span>
<input type="text" class="form-control" name="checkout_date_end" aria-label="checkout_date_end" value="{{ $template->textValue('checkout_date_end', old('checkout_date_end')) }}">
@@ -464,7 +464,7 @@
<!-- Last Checkin Date -->
<div class="form-group checkin-range{{ ($errors->has('checkin_date_start') || $errors->has('checkin_date_end')) ? ' has-error' : '' }}">
<label for="checkin_date" class="col-md-3 control-label">{{ trans('admin/hardware/table.last_checkin_date') }}</label>
<div class="input-daterange input-group col-md-7" id="datepicker">
<div class="input-daterange input-group col-md-7" id="checkin-range-datepicker">
<input type="text" class="form-control" name="checkin_date_start" aria-label="checkin_date_start" value="{{ $template->textValue('checkin_date_start', old('checkin_date_start')) }}">
<span class="input-group-addon">{{ strtolower(trans('general.to')) }}</span>
<input type="text" class="form-control" name="checkin_date_end" aria-label="checkin_date_end" value="{{ $template->textValue('checkin_date_end', old('checkin_date_end')) }}">
@@ -481,7 +481,7 @@
<!-- Expected Checkin Date -->
<div class="form-group expected_checkin-range{{ ($errors->has('expected_checkin_start') || $errors->has('expected_checkin_end')) ? ' has-error' : '' }}">
<label for="expected_checkin_start" class="col-md-3 control-label">{{ trans('admin/hardware/form.expected_checkin') }}</label>
<div class="input-daterange input-group col-md-7" id="datepicker">
<div class="input-daterange input-group col-md-7" id="expected_checkin-range-datepicker">
<input type="text" class="form-control" name="expected_checkin_start" aria-label="expected_checkin_start" value="{{ $template->textValue('expected_checkin_start', old('expected_checkin_start')) }}">
<span class="input-group-addon">{{ strtolower(trans('general.to')) }}</span>
<input type="text" class="form-control" name="expected_checkin_end" aria-label="expected_checkin_end" value="{{ $template->textValue('expected_checkin_end', old('expected_checkin_end')) }}">
@@ -499,7 +499,7 @@
<!-- EoL Date -->
<div class="form-group asset_eol_date-range {{ ($errors->has('asset_eol_date_start') || $errors->has('asset_eol_date_end')) ? ' has-error' : '' }}">
<label for="asset_eol_date" class="col-md-3 control-label">{{ trans('admin/hardware/form.eol_date') }}</label>
<div class="input-daterange input-group col-md-7" id="datepicker">
<div class="input-daterange input-group col-md-7" id="asset_eol_date-range-datepicker">
<input type="text" class="form-control" name="asset_eol_date_start" aria-label="asset_eol_date_start" value="{{ $template->textValue('asset_eol_date_start', old('asset_eol_date_start')) }}">
<span class="input-group-addon">to</span>
<input type="text" class="form-control" name="asset_eol_date_end" aria-label="asset_eol_date_end" value="{{ $template->textValue('asset_eol_date_end', old('asset_eol_date_end')) }}">
@@ -516,7 +516,7 @@
<!-- Last Audit Date -->
<div class="form-group last_audit-range{{ ($errors->has('last_audit_start') || $errors->has('last_audit_end')) ? ' has-error' : '' }}">
<label for="last_audit_start" class="col-md-3 control-label">{{ trans('general.last_audit') }}</label>
<div class="input-daterange input-group col-md-7" id="datepicker">
<div class="input-daterange input-group col-md-7" id="last_audit-range-datepicker">
<input type="text" class="form-control" name="last_audit_start" aria-label="last_audit_start" value="{{ $template->textValue('last_audit_start', old('last_audit_start')) }}">
<span class="input-group-addon">{{ strtolower(trans('general.to')) }}</span>
<input type="text" class="form-control" name="last_audit_end" aria-label="last_audit_end" value="{{ $template->textValue('last_audit_end', old('last_audit_end')) }}">
@@ -533,7 +533,7 @@
<!-- Next Audit Date -->
<div class="form-group next_audit-range{{ ($errors->has('next_audit_start') || $errors->has('next_audit_end')) ? ' has-error' : '' }}">
<label for="next_audit_start" class="col-md-3 control-label">{{ trans('general.next_audit_date') }}</label>
<div class="input-daterange input-group col-md-7" id="datepicker">
<div class="input-daterange input-group col-md-7" id="next_audit-range-datepicker">
<input type="text" class="form-control" name="next_audit_start" aria-label="next_audit_start" value="{{ $template->textValue('next_audit_start', old('next_audit_start')) }}">
<span class="input-group-addon">{{ strtolower(trans('general.to')) }}</span>
<input type="text" class="form-control" name="next_audit_end" aria-label="next_audit_end" value="{{ $template->textValue('next_audit_end', old('next_audit_end')) }}">
@@ -547,6 +547,24 @@
@endif
</div>
<!-- Last updated Date -->
<div class="form-group last_updated-range{{ ($errors->has('last_updated_start') || $errors->has('last_updated_end')) ? ' has-error' : '' }}">
<label for="last_updated_start" class="col-md-3 control-label">{{ trans('general.updated_at') }}</label>
<div class="input-daterange input-group col-md-7" id="last_updated-range-datepicker">
<input type="text" class="form-control" name="last_updated_start" aria-label="last_updated_start" value="{{ $template->textValue('last_updated_start', old('last_updated_start')) }}">
<span class="input-group-addon">{{ strtolower(trans('general.to')) }}</span>
<input type="text" class="form-control" name="last_updated_end" aria-label="last_updated_end" value="{{ $template->textValue('last_updated_end', old('last_updated_end')) }}">
</div>
@if ($errors->has('last_updated_start') || $errors->has('last_updated_end'))
<div class="col-md-9 col-lg-offset-3">
{!! $errors->first('last_updated_start', '<span class="alert-msg" aria-hidden="true"><i class="fas fa-times" aria-hidden="true"></i> :message</span>') !!}
{!! $errors->first('last_updated_end', '<span class="alert-msg" aria-hidden="true"><i class="fas fa-times" aria-hidden="true"></i> :message</span>') !!}
</div>
@endif
</div>
<div class="col-md-9 col-md-offset-3">
<label class="form-control">
<input type="checkbox" name="exclude_archived" value="1" @checked($template->checkmarkValue('exclude_archived', '0')) />
@@ -759,6 +777,14 @@
format: 'yyyy-mm-dd'
});
$('.last_updated-range .input-daterange').datepicker({
clearBtn: true,
todayHighlight: true,
endDate:'0d',
format: 'yyyy-mm-dd'
});
$("#checkAll").change(function () {
$("#included_fields_wrapper input:checkbox").prop('checked', $(this).prop("checked"));
});

View File

@@ -511,7 +511,7 @@ Route::group(['prefix' => 'v1', 'middleware' => ['api', 'throttle:api']], functi
->where(['action' => 'audit|audits|checkins', 'upcoming_status' => 'due|overdue|due-or-overdue']);
// Legacy URL for audit
// Bulk audit for RFID, also works as a legacy endpoint
Route::post('audit',
[
Api\AssetsController::class,

View File

@@ -179,11 +179,22 @@ create_user () {
if [[ "$distro" == "Ubuntu" ]] || [[ "$distro" == "Debian" ]] || [[ "$distro" == "Raspbian" ]] ; then
/usr/sbin/adduser --quiet --disabled-password --gecos 'Snipe-IT User' "$APP_USER"
su -c "/usr/sbin/usermod -a -G "$apache_group" "$APP_USER""
else
adduser "$APP_USER"
usermod -a -G "$apache_group" "$APP_USER"
adduser -c "Snipe-IT User" "$APP_USER"
fi
# Add the user to the apache group so the app can write to any files apache
# creates (eg, if apache process creates the log, but then a an app-user-owned
# cron also tries writing
usermod -a -G "$apache_group" "$APP_USER"
# Now do the reverse -- so apache can write to the log that the user may
# have created. This was actively a problem on new installs, hobbling
# imports
# redefining these variables just for clarity
apache_user="$apache_group"
app_group="$APP_USER"
usermod -a -G "$app_group" "$apache_user"
}
run_as_app_user () {

View File

@@ -53,6 +53,36 @@ class AuditAssetTest extends TestCase
}
public function testAssetAuditWithTagsArrayIsSaved()
{
$asset1 = Asset::factory()->create();
$asset2 = Asset::factory()->create();
$asset3 = Asset::factory()->create();
$this->actingAsForApi(User::factory()->auditAssets()->create())
->postJson(route('api.asset.audit.legacy'), [
'asset_tag' => [
$asset1->asset_tag,
$asset2->asset_tag,
$asset3->asset_tag
],
'note' => 'test',
])
->assertStatusMessageIs('success')
->assertJson(
[
'messages' =>trans('admin/hardware/message.audit.success'),
'payload' => [
'id' => $asset1->id,
'asset_tag' => $asset1->asset_tag,
'note' => 'test'
],
])
->assertStatus(200);
}
public function testAssetAuditIsSaved()
{
$asset = Asset::factory()->create();

View File

@@ -32,6 +32,7 @@ class LoginTest extends TestCase
public function testLoginThrottleConfigIsRespected()
{
$this->markTestIncomplete("This test is flaky and needs to be fixed. Passes and fails seemingly at random.");
User::factory()->create(['username' => 'username_here']);
config(['auth.passwords.users.throttle.max_attempts' => 1]);
@@ -62,6 +63,7 @@ class LoginTest extends TestCase
public function testLogsSuccessfulLogin()
{
$this->markTestIncomplete("This test is flaky and needs to be fixed. Passes and fails seemingly at random.");
User::factory()->create(['username' => 'username_here']);
$this->withServerVariables(['REMOTE_ADDR' => '127.0.0.100'])