mirror of
https://github.com/snipe/snipe-it.git
synced 2025-01-13 06:47:46 -08:00
Merge branch 'develop' into fix/test-suite
This commit is contained in:
commit
d27fe7d4b9
|
@ -6,6 +6,7 @@ use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
|
||||||
use App\Helpers\Helper;
|
use App\Helpers\Helper;
|
||||||
use Illuminate\Validation\ValidationException;
|
use Illuminate\Validation\ValidationException;
|
||||||
use Illuminate\Auth\AuthenticationException;
|
use Illuminate\Auth\AuthenticationException;
|
||||||
|
use ArieTimmerman\Laravel\SCIMServer\Exceptions\SCIMException;
|
||||||
use Log;
|
use Log;
|
||||||
use Throwable;
|
use Throwable;
|
||||||
use JsonException;
|
use JsonException;
|
||||||
|
@ -28,6 +29,7 @@ class Handler extends ExceptionHandler
|
||||||
\Intervention\Image\Exception\NotSupportedException::class,
|
\Intervention\Image\Exception\NotSupportedException::class,
|
||||||
\League\OAuth2\Server\Exception\OAuthServerException::class,
|
\League\OAuth2\Server\Exception\OAuthServerException::class,
|
||||||
JsonException::class,
|
JsonException::class,
|
||||||
|
SCIMException::class, //these generally don't need to be reported
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -53,7 +55,7 @@ class Handler extends ExceptionHandler
|
||||||
*
|
*
|
||||||
* @param \Illuminate\Http\Request $request
|
* @param \Illuminate\Http\Request $request
|
||||||
* @param \Exception $e
|
* @param \Exception $e
|
||||||
* @return \Illuminate\Http\Response
|
* @return \Illuminate\Http\JsonResponse|\Illuminate\Http\RedirectResponse|\Illuminate\Http\Response
|
||||||
*/
|
*/
|
||||||
public function render($request, Throwable $e)
|
public function render($request, Throwable $e)
|
||||||
{
|
{
|
||||||
|
@ -70,6 +72,9 @@ class Handler extends ExceptionHandler
|
||||||
return response()->json(Helper::formatStandardApiResponse('error', null, 'invalid JSON'), 422);
|
return response()->json(Helper::formatStandardApiResponse('error', null, 'invalid JSON'), 422);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($e instanceof SCIMException) {
|
||||||
|
return response()->json(Helper::formatStandardApiResponse('error', null, 'invalid SCIM Request'), 400);
|
||||||
|
}
|
||||||
|
|
||||||
// Handle Ajax requests that fail because the model doesn't exist
|
// Handle Ajax requests that fail because the model doesn't exist
|
||||||
if ($request->ajax() || $request->wantsJson()) {
|
if ($request->ajax() || $request->wantsJson()) {
|
||||||
|
@ -113,8 +118,8 @@ class Handler extends ExceptionHandler
|
||||||
*
|
*
|
||||||
* @param \Illuminate\Http\Request $request
|
* @param \Illuminate\Http\Request $request
|
||||||
* @param \Illuminate\Auth\AuthenticationException $exception
|
* @param \Illuminate\Auth\AuthenticationException $exception
|
||||||
* @return \Illuminate\Http\Response
|
* @return \Illuminate\Http\JsonResponse|\Illuminate\Http\RedirectResponse
|
||||||
*/
|
*/
|
||||||
protected function unauthenticated($request, AuthenticationException $exception)
|
protected function unauthenticated($request, AuthenticationException $exception)
|
||||||
{
|
{
|
||||||
if ($request->expectsJson()) {
|
if ($request->expectsJson()) {
|
||||||
|
|
|
@ -126,7 +126,14 @@ class ImportController extends Controller
|
||||||
}
|
}
|
||||||
$file_name = date('Y-m-d-his').'-'.$fixed_filename;
|
$file_name = date('Y-m-d-his').'-'.$fixed_filename;
|
||||||
$import->file_path = $file_name;
|
$import->file_path = $file_name;
|
||||||
|
$import->filesize = null;
|
||||||
|
|
||||||
|
if (!file_exists($path.'/'.$file_name)) {
|
||||||
|
return response()->json(Helper::formatStandardApiResponse('error', null, trans('general.file_not_found')), 500);
|
||||||
|
}
|
||||||
|
|
||||||
$import->filesize = filesize($path.'/'.$file_name);
|
$import->filesize = filesize($path.'/'.$file_name);
|
||||||
|
|
||||||
$import->save();
|
$import->save();
|
||||||
$results[] = $import;
|
$results[] = $import;
|
||||||
}
|
}
|
||||||
|
|
|
@ -271,7 +271,7 @@ class SettingsController extends Controller
|
||||||
$headers = ['ContentType' => 'application/zip'];
|
$headers = ['ContentType' => 'application/zip'];
|
||||||
return Storage::download($path.'/'.$file, $file, $headers);
|
return Storage::download($path.'/'.$file, $file, $headers);
|
||||||
} else {
|
} else {
|
||||||
return response()->json(Helper::formatStandardApiResponse('error', null, 'File not found'));
|
return response()->json(Helper::formatStandardApiResponse('error', null, trans('general.file_not_found')));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -61,7 +61,7 @@ class LicenseCheckinController extends Controller
|
||||||
$license = License::find($licenseSeat->license_id);
|
$license = License::find($licenseSeat->license_id);
|
||||||
|
|
||||||
// LicenseSeat is not assigned, it can't be checked in
|
// LicenseSeat is not assigned, it can't be checked in
|
||||||
if (is_null($licenseSeat->assignedTo) && is_null($licenseSeat->asset_id)) {
|
if (is_null($licenseSeat->assigned_to) && is_null($licenseSeat->asset_id)) {
|
||||||
return redirect()->route('licenses.index')->with('error', trans('admin/licenses/message.checkin.error'));
|
return redirect()->route('licenses.index')->with('error', trans('admin/licenses/message.checkin.error'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -65,18 +65,27 @@ class SettingsController extends Controller
|
||||||
$start_settings['db_error'] = $e->getMessage();
|
$start_settings['db_error'] = $e->getMessage();
|
||||||
}
|
}
|
||||||
|
|
||||||
$protocol = array_key_exists('HTTPS', $_SERVER) && ('on' == $_SERVER['HTTPS']) ? 'https://' : 'http://';
|
if (array_key_exists("HTTP_X_FORWARDED_PROTO", $_SERVER)) {
|
||||||
|
$protocol = $_SERVER["HTTP_X_FORWARDED_PROTO"] . "://";
|
||||||
|
} elseif (array_key_exists('HTTPS', $_SERVER) && ('on' == $_SERVER['HTTPS'])) {
|
||||||
|
$protocol = "https://";
|
||||||
|
} else {
|
||||||
|
$protocol = "http://";
|
||||||
|
}
|
||||||
|
|
||||||
$host = array_key_exists('SERVER_NAME', $_SERVER) ? $_SERVER['SERVER_NAME'] : null;
|
if (array_key_exists("HTTP_X_FORWARDED_HOST", $_SERVER)) {
|
||||||
$port = array_key_exists('SERVER_PORT', $_SERVER) ? $_SERVER['SERVER_PORT'] : null;
|
$host = $_SERVER["HTTP_X_FORWARDED_HOST"];
|
||||||
if (('http://' === $protocol && '80' != $port) || ('https://' === $protocol && '443' != $port)) {
|
} else {
|
||||||
$host .= ':'.$port;
|
$host = array_key_exists('SERVER_NAME', $_SERVER) ? $_SERVER['SERVER_NAME'] : null;
|
||||||
|
$port = array_key_exists('SERVER_PORT', $_SERVER) ? $_SERVER['SERVER_PORT'] : null;
|
||||||
|
if (('http://' === $protocol && '80' != $port) || ('https://' === $protocol && '443' != $port)) {
|
||||||
|
$host .= ':'.$port;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
$pageURL = $protocol.$host.$_SERVER['REQUEST_URI'];
|
$pageURL = $protocol.$host.$_SERVER['REQUEST_URI'];
|
||||||
|
|
||||||
$start_settings['url_valid'] = (url('/').'/setup' === $pageURL);
|
$start_settings['url_config'] = url('/').'/setup';
|
||||||
|
$start_settings['url_valid'] = ($start_settings['url_config'] === $pageURL);
|
||||||
$start_settings['url_config'] = url('/');
|
|
||||||
$start_settings['real_url'] = $pageURL;
|
$start_settings['real_url'] = $pageURL;
|
||||||
$start_settings['php_version_min'] = true;
|
$start_settings['php_version_min'] = true;
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,7 @@ class Depreciation extends SnipeModel
|
||||||
// Declare the rules for the form validation
|
// Declare the rules for the form validation
|
||||||
protected $rules = [
|
protected $rules = [
|
||||||
'name' => 'required|min:3|max:255|unique:depreciations,name',
|
'name' => 'required|min:3|max:255|unique:depreciations,name',
|
||||||
'months' => 'required|max:3600|integer',
|
'months' => 'required|max:3600|integer|gt:0',
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -117,6 +117,11 @@ $config = [
|
||||||
\Log::info("IGNORING E_WARNING in production mode: ".$args->getMessage());
|
\Log::info("IGNORING E_WARNING in production mode: ".$args->getMessage());
|
||||||
return true; // "TRUE - you should ignore it!"
|
return true; // "TRUE - you should ignore it!"
|
||||||
}
|
}
|
||||||
|
$needle = "ArieTimmerman\\Laravel\\SCIMServer\\Exceptions\\SCIMException";
|
||||||
|
if (App::environment('production') && is_string($args) && strncmp($args, $needle, strlen($needle) ) === 0 ) {
|
||||||
|
\Log::info("String: '$args' looks like a SCIM Exception; ignoring error");
|
||||||
|
return true; //yes, *do* ignore it
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
|
|
@ -55,7 +55,7 @@ class ActionlogFactory extends Factory
|
||||||
[
|
[
|
||||||
'assigned_to' => $target->id,
|
'assigned_to' => $target->id,
|
||||||
'assigned_type' => \App\Models\User::class,
|
'assigned_type' => \App\Models\User::class,
|
||||||
'assigned_to' => $target->location_id,
|
'location_id' => $target->location_id,
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -84,7 +84,7 @@ class ActionlogFactory extends Factory
|
||||||
[
|
[
|
||||||
'assigned_to' => $target->id,
|
'assigned_to' => $target->id,
|
||||||
'assigned_type' => \App\Models\Location::class,
|
'assigned_type' => \App\Models\Location::class,
|
||||||
'assigned_to' => $target->id,
|
'location_id' => $target->id,
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -395,7 +395,7 @@ return [
|
||||||
'end_date' => 'Enddatum',
|
'end_date' => 'Enddatum',
|
||||||
'alt_uploaded_image_thumbnail' => 'Hochgeladene Miniaturansicht',
|
'alt_uploaded_image_thumbnail' => 'Hochgeladene Miniaturansicht',
|
||||||
'placeholder_kit' => 'Kit auswählen',
|
'placeholder_kit' => 'Kit auswählen',
|
||||||
'file_not_found' => 'File not found',
|
'file_not_found' => 'File not found on server',
|
||||||
'preview_not_available' => '(no preview)',
|
'preview_not_available' => '(no preview)',
|
||||||
'setup' => 'Setup',
|
'setup' => 'Setup',
|
||||||
'pre_flight' => 'Pre-Flight',
|
'pre_flight' => 'Pre-Flight',
|
||||||
|
|
|
@ -41,7 +41,7 @@
|
||||||
|
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th data-switchable="true" data-sortable="false" data-field="id" data-visible="false">{{ trans('general.id') }}</th>
|
<th data-switchable="true" data-sortable="true" data-field="id" data-visible="false">{{ trans('general.id') }}</th>
|
||||||
<th data-switchable="true" data-sortable="true" data-field="name" data-formatter="groupsAdminLinkFormatter" data-visible="true">{{ trans('admin/groups/table.name') }}</th>
|
<th data-switchable="true" data-sortable="true" data-field="name" data-formatter="groupsAdminLinkFormatter" data-visible="true">{{ trans('admin/groups/table.name') }}</th>
|
||||||
<th data-switchable="true" data-sortable="true" data-field="users_count" data-visible="true">{{ trans('admin/groups/table.users') }}</th>
|
<th data-switchable="true" data-sortable="true" data-field="users_count" data-visible="true">{{ trans('admin/groups/table.users') }}</th>
|
||||||
<th data-switchable="true" data-sortable="true" data-field="created_at" data-visible="true" data-formatter="dateDisplayFormatter">{{ trans('general.created_at') }}</th>
|
<th data-switchable="true" data-sortable="true" data-field="created_at" data-visible="true" data-formatter="dateDisplayFormatter">{{ trans('general.created_at') }}</th>
|
||||||
|
|
Loading…
Reference in a new issue