Skip to content

A free open source IT asset/license management system

Merge remote-tracking branch 'origin/master' into develop

snipedd5f812d88c0
diff --cc .all-contributorsrc
index d8a5df3d4d,b85a13aa98..a47bf5b0ce
--- a/.all-contributorsrc
+++ b/.all-contributorsrc
@@@ -2514,15 -2505,15 +2514,24 @@@
"code"
]
},
- {
++ {
+ "login": "Haxatron",
+ "name": "Haxatron",
+ "avatar_url": "https://avatars.githubusercontent.com/u/76475453?v=4",
+ "profile": "https://github.com/Haxatron",
+ "contributions": [
+ "code"
+ ]
+ },
+ {
+ "login": "PlaneNuts",
+ "name": "PlaneNuts",
+ "avatar_url": "https://avatars.githubusercontent.com/u/88776392?v=4",
+ "profile": "https://github.com/PlaneNuts",
+ "contributions": [
+ "code"
+ ]
+ },
{
"login": "exula",
"name": "Bradley Coudriet",
@@@ -2532,24 -2523,15 +2541,33 @@@
"code"
]
},
- {
++ {
+ "login": "UniversalSuperBox",
+ "name": "Dalton Durst",
+ "avatar_url": "https://avatars.githubusercontent.com/u/21966173?v=4",
+ "profile": "https://daltondur.st",
+ "contributions": [
+ "code"
+ ]
+ },
+ {
+ "login": "adagioajanes",
+ "name": "Alex Janes",
+ "avatar_url": "https://avatars.githubusercontent.com/u/38761237?v=4",
+ "profile": "https://adagiohealth.org",
+ "contributions": [
+ "code"
+ ]
+ },
+ {
+ "login": "nuraeil",
+ "name": "Nuraeil",
+ "avatar_url": "https://avatars.githubusercontent.com/u/32387849?v=4",
+ "profile": "https://github.com/nuraeil",
+ "contributions": [
+ "code"
+ ]
+ },
{
"login": "TenOfTens",
"name": "TenOfTens",
diff --cc README.md
index 4812fb522f,88648fa056..837fdfcc77
--- a/README.md
+++ b/README.md
@@@ -128,10 -128,9 +128,10 @@@ Thanks goes to all of these wonderful p
| [<img src="https://avatars.githubusercontent.com/u/9255772?v=4" width="110px;"/><br /><sub>Mark Stenglein</sub>](https://markstenglein.com)<br />[πŸ’»](https://github.com/snipe/snipe-it/commits?author=ocelotsloth "Code") | [<img src="https://avatars.githubusercontent.com/u/35658596?v=4" width="110px;"/><br /><sub>ajsy</sub>](https://github.com/ajsy)<br />[πŸ’»](https://github.com/snipe/snipe-it/commits?author=ajsy "Code") | [<img src="https://avatars.githubusercontent.com/u/3628035?v=4" width="110px;"/><br /><sub>Jan Kiesewetter</sub>](https://github.com/t3easy)<br />[πŸ’»](https://github.com/snipe/snipe-it/commits?author=t3easy "Code") | [<img src="https://avatars.githubusercontent.com/u/79449630?v=4" width="110px;"/><br /><sub>Tetrachloromethane250</sub>](https://github.com/Tetrachloromethane250)<br />[πŸ’»](https://github.com/snipe/snipe-it/commits?author=Tetrachloromethane250 "Code") | [<img src="https://avatars.githubusercontent.com/u/22004482?v=4" width="110px;"/><br /><sub>Lars Kajes</sub>](https://www.kajes.se/)<br />[πŸ’»](https://github.com/snipe/snipe-it/commits?author=kajes "Code") | [<img src="https://avatars.githubusercontent.com/u/13993216?v=4" width="110px;"/><br /><sub>Joly0</sub>](https://github.com/Joly0)<br />[πŸ’»](https://github.com/snipe/snipe-it/commits?author=Joly0 "Code") | [<img src="https://avatars.githubusercontent.com/u/1501022?v=4" width="110px;"/><br /><sub>theburger</sub>](https://github.com/limeless)<br />[πŸ’»](https://github.com/snipe/snipe-it/commits?author=limeless "Code") |
| [<img src="https://avatars.githubusercontent.com/u/36065681?v=4" width="110px;"/><br /><sub>David Valin Alonso</sub>](https://github.com/deivishome)<br />[πŸ’»](https://github.com/snipe/snipe-it/commits?author=deivishome "Code") | [<img src="https://avatars.githubusercontent.com/u/8290389?v=4" width="110px;"/><br /><sub>andreaci</sub>](https://github.com/andreaci)<br />[πŸ’»](https://github.com/snipe/snipe-it/commits?author=andreaci "Code") | [<img src="https://avatars.githubusercontent.com/u/1828542?v=4" width="110px;"/><br /><sub>Jelle Sebreghts</sub>](http://www.jellesebreghts.be)<br />[πŸ’»](https://github.com/snipe/snipe-it/commits?author=Jelle-S "Code") | [<img src="https://avatars.githubusercontent.com/u/11180862?v=4" width="110px;"/><br /><sub>Michael Pietsch</sub>](https://github.com/Skywalker-11)<br /> | [<img src="https://avatars.githubusercontent.com/u/22068886?v=4" width="110px;"/><br /><sub>Masudul Haque Shihab</sub>](https://github.com/sh1hab)<br />[πŸ’»](https://github.com/snipe/snipe-it/commits?author=sh1hab "Code") | [<img src="https://avatars.githubusercontent.com/u/16099942?v=4" width="110px;"/><br /><sub>Supapong Areeprasertkul</sub>](http://www.freedomdive.com/)<br />[πŸ’»](https://github.com/snipe/snipe-it/commits?author=zybersup "Code") | [<img src="https://avatars.githubusercontent.com/u/207358?v=4" width="110px;"/><br /><sub>Peter Sarossy</sub>](https://github.com/psarossy)<br />[πŸ’»](https://github.com/snipe/snipe-it/commits?author=psarossy "Code") |
| [<img src="https://avatars.githubusercontent.com/u/11823649?v=4" width="110px;"/><br /><sub>Renee Margaret McConahy</sub>](https://github.com/nepella)<br />[πŸ’»](https://github.com/snipe/snipe-it/commits?author=nepella "Code") | [<img src="https://avatars.githubusercontent.com/u/5553884?v=4" width="110px;"/><br /><sub>JohnnyPicnic</sub>](https://github.com/JohnnyPicnic)<br />[πŸ’»](https://github.com/snipe/snipe-it/commits?author=JohnnyPicnic "Code") | [<img src="https://avatars.githubusercontent.com/u/8799594?v=4" width="110px;"/><br /><sub>markbrule</sub>](https://github.com/markbrule)<br />[πŸ’»](https://github.com/snipe/snipe-it/commits?author=markbrule "Code") | [<img src="https://avatars.githubusercontent.com/u/1962801?v=4" width="110px;"/><br /><sub>Mike Campbell</sub>](https://github.com/mikecmpbll)<br />[πŸ’»](https://github.com/snipe/snipe-it/commits?author=mikecmpbll "Code") | [<img src="https://avatars.githubusercontent.com/u/11973217?v=4" width="110px;"/><br /><sub>tbrconnect</sub>](https://github.com/tbrconnect)<br />[πŸ’»](https://github.com/snipe/snipe-it/commits?author=tbrconnect "Code") | [<img src="https://avatars.githubusercontent.com/u/12447225?v=4" width="110px;"/><br /><sub>kcoyo</sub>](https://github.com/kcoyo)<br />[πŸ’»](https://github.com/snipe/snipe-it/commits?author=kcoyo "Code") | [<img src="https://avatars.githubusercontent.com/u/494017?v=4" width="110px;"/><br /><sub>Travis Miller</sub>](https://travismiller.com/)<br />[πŸ’»](https://github.com/snipe/snipe-it/commits?author=travismiller "Code") |
- | [<img src="https://avatars.githubusercontent.com/u/1975640?v=4" width="110px;"/><br /><sub>Evan Taylor</sub>](https://github.com/Delta5)<br />[πŸ’»](https://github.com/snipe/snipe-it/commits?author=Delta5 "Code") | [<img src="https://avatars.githubusercontent.com/u/8735148?v=4" width="110px;"/><br /><sub>Petri Asikainen</sub>](https://github.com/PetriAsi)<br />[πŸ’»](https://github.com/snipe/snipe-it/commits?author=PetriAsi "Code") | [<img src="https://avatars.githubusercontent.com/u/11424540?v=4" width="110px;"/><br /><sub>derdeagle</sub>](https://github.com/derdeagle)<br />[πŸ’»](https://github.com/snipe/snipe-it/commits?author=derdeagle "Code") | [<img src="https://avatars.githubusercontent.com/u/176950?v=4" width="110px;"/><br /><sub>Mike Frysinger</sub>](https://wh0rd.org/)<br />[πŸ’»](https://github.com/snipe/snipe-it/commits?author=vapier "Code") | [<img src="https://avatars.githubusercontent.com/u/22044358?v=4" width="110px;"/><br /><sub>ALPHA</sub>](https://github.com/AL4AL)<br />[πŸ’»](https://github.com/snipe/snipe-it/commits?author=AL4AL "Code") | [<img src="https://avatars.githubusercontent.com/u/1042587?v=4" width="110px;"/><br /><sub>FliegenKLATSCH</sub>](https://www.ifern.de)<br />[πŸ’»](https://github.com/snipe/snipe-it/commits?author=FliegenKLATSCH "Code") | [<img src="https://avatars.githubusercontent.com/u/442138?v=4" width="110px;"/><br /><sub>Jeremy Price</sub>](https://github.com/jerm)<br />[πŸ’»](https://github.com/snipe/snipe-it/commits?author=jerm "Code") |
- | [<img src="https://avatars.githubusercontent.com/u/84392209?v=4" width="110px;"/><br /><sub>Toreg87</sub>](https://github.com/Toreg87)<br />[πŸ’»](https://github.com/snipe/snipe-it/commits?author=Toreg87 "Code") | [<img src="https://avatars.githubusercontent.com/u/67638596?v=4" width="110px;"/><br /><sub>Matthew Nickson</sub>](https://github.com/Computroniks)<br />[πŸ’»](https://github.com/snipe/snipe-it/commits?author=Computroniks "Code") | [<img src="https://avatars.githubusercontent.com/u/1646397?v=4" width="110px;"/><br /><sub>Jethro Nederhof</sub>](https://jethron.id.au)<br />[πŸ’»](https://github.com/snipe/snipe-it/commits?author=jethron "Code") | [<img src="https://avatars.githubusercontent.com/u/23289826?v=4" width="110px;"/><br /><sub>Oskar Stenberg</sub>](https://github.com/01ste02)<br />[πŸ’»](https://github.com/snipe/snipe-it/commits?author=01ste02 "Code") | [<img src="https://avatars.githubusercontent.com/u/82208283?v=4" width="110px;"/><br /><sub>Robert-Azelis</sub>](https://github.com/Robert-Azelis)<br />[πŸ’»](https://github.com/snipe/snipe-it/commits?author=Robert-Azelis "Code") | [<img src="https://avatars.githubusercontent.com/u/60648387?v=4" width="110px;"/><br /><sub>Alexander William Smith</sub>](https://github.com/alwism)<br />[πŸ’»](https://github.com/snipe/snipe-it/commits?author=alwism "Code") | [<img src="https://avatars.githubusercontent.com/u/24418301?v=4" width="110px;"/><br /><sub>LEITWERK AG</sub>](https://www.leitwerk.de/)<br />[πŸ’»](https://github.com/snipe/snipe-it/commits?author=leitwerk-ag "Code") |
- | [<img src="https://avatars.githubusercontent.com/u/1911435?v=4" width="110px;"/><br /><sub>Adam</sub>](http://www.aboutcher.co.uk)<br />[πŸ’»](https://github.com/snipe/snipe-it/commits?author=adamboutcher "Code") | [<img src="https://avatars.githubusercontent.com/u/16104273?v=4" width="110px;"/><br /><sub>Ian</sub>](https://snksrv.com)<br />[πŸ’»](https://github.com/snipe/snipe-it/commits?author=sneak-it "Code") | [<img src="https://avatars.githubusercontent.com/u/4023909?v=4" width="110px;"/><br /><sub>Shao Yu-Lung (Allen)</sub>](http://blog.bestlong.idv.tw/)<br />[πŸ’»](https://github.com/snipe/snipe-it/commits?author=bestlong "Code") | [<img src="https://avatars.githubusercontent.com/u/88776392?v=4" width="110px;"/><br /><sub>PlaneNuts</sub>](https://github.com/PlaneNuts)<br />[πŸ’»](https://github.com/snipe/snipe-it/commits?author=PlaneNuts "Code") | [<img src="https://avatars.githubusercontent.com/u/3842948?v=4" width="110px;"/><br /><sub>Bradley Coudriet</sub>](http://bjcpgd.cias.rit.edu)<br />[πŸ’»](https://github.com/snipe/snipe-it/commits?author=exula "Code") | [<img src="https://avatars.githubusercontent.com/u/38761237?v=4" width="110px;"/><br /><sub>Alex Janes</sub>](https://adagiohealth.org)<br />[πŸ’»](https://github.com/snipe/snipe-it/commits?author=adagioajanes "Code") | [<img src="https://avatars.githubusercontent.com/u/32387849?v=4" width="110px;"/><br /><sub>Nuraeil</sub>](https://github.com/nuraeil)<br />[πŸ’»](https://github.com/snipe/snipe-it/commits?author=nuraeil "Code") |
+ | [<img src="https://avatars.githubusercontent.com/u/8735148?v=4" width="110px;"/><br /><sub>Petri Asikainen</sub>](https://github.com/PetriAsi)<br />[πŸ’»](https://github.com/snipe/snipe-it/commits?author=PetriAsi "Code") | [<img src="https://avatars.githubusercontent.com/u/11424540?v=4" width="110px;"/><br /><sub>derdeagle</sub>](https://github.com/derdeagle)<br />[πŸ’»](https://github.com/snipe/snipe-it/commits?author=derdeagle "Code") | [<img src="https://avatars.githubusercontent.com/u/176950?v=4" width="110px;"/><br /><sub>Mike Frysinger</sub>](https://wh0rd.org/)<br />[πŸ’»](https://github.com/snipe/snipe-it/commits?author=vapier "Code") | [<img src="https://avatars.githubusercontent.com/u/22044358?v=4" width="110px;"/><br /><sub>ALPHA</sub>](https://github.com/AL4AL)<br />[πŸ’»](https://github.com/snipe/snipe-it/commits?author=AL4AL "Code") | [<img src="https://avatars.githubusercontent.com/u/1042587?v=4" width="110px;"/><br /><sub>FliegenKLATSCH</sub>](https://www.ifern.de)<br />[πŸ’»](https://github.com/snipe/snipe-it/commits?author=FliegenKLATSCH "Code") | [<img src="https://avatars.githubusercontent.com/u/442138?v=4" width="110px;"/><br /><sub>Jeremy Price</sub>](https://github.com/jerm)<br />[πŸ’»](https://github.com/snipe/snipe-it/commits?author=jerm "Code") | [<img src="https://avatars.githubusercontent.com/u/84392209?v=4" width="110px;"/><br /><sub>Toreg87</sub>](https://github.com/Toreg87)<br />[πŸ’»](https://github.com/snipe/snipe-it/commits?author=Toreg87 "Code") |
+ | [<img src="https://avatars.githubusercontent.com/u/67638596?v=4" width="110px;"/><br /><sub>Matthew Nickson</sub>](https://github.com/Computroniks)<br />[πŸ’»](https://github.com/snipe/snipe-it/commits?author=Computroniks "Code") | [<img src="https://avatars.githubusercontent.com/u/1646397?v=4" width="110px;"/><br /><sub>Jethro Nederhof</sub>](https://jethron.id.au)<br />[πŸ’»](https://github.com/snipe/snipe-it/commits?author=jethron "Code") | [<img src="https://avatars.githubusercontent.com/u/23289826?v=4" width="110px;"/><br /><sub>Oskar Stenberg</sub>](https://github.com/01ste02)<br />[πŸ’»](https://github.com/snipe/snipe-it/commits?author=01ste02 "Code") | [<img src="https://avatars.githubusercontent.com/u/82208283?v=4" width="110px;"/><br /><sub>Robert-Azelis</sub>](https://github.com/Robert-Azelis)<br />[πŸ’»](https://github.com/snipe/snipe-it/commits?author=Robert-Azelis "Code") | [<img src="https://avatars.githubusercontent.com/u/60648387?v=4" width="110px;"/><br /><sub>Alexander William Smith</sub>](https://github.com/alwism)<br />[πŸ’»](https://github.com/snipe/snipe-it/commits?author=alwism "Code") | [<img src="https://avatars.githubusercontent.com/u/24418301?v=4" width="110px;"/><br /><sub>LEITWERK AG</sub>](https://www.leitwerk.de/)<br />[πŸ’»](https://github.com/snipe/snipe-it/commits?author=leitwerk-ag "Code") | [<img src="https://avatars.githubusercontent.com/u/1911435?v=4" width="110px;"/><br /><sub>Adam</sub>](http://www.aboutcher.co.uk)<br />[πŸ’»](https://github.com/snipe/snipe-it/commits?author=adamboutcher "Code") |
+ | [<img src="https://avatars.githubusercontent.com/u/16104273?v=4" width="110px;"/><br /><sub>Ian</sub>](https://snksrv.com)<br />[πŸ’»](https://github.com/snipe/snipe-it/commits?author=sneak-it "Code") | [<img src="https://avatars.githubusercontent.com/u/4023909?v=4" width="110px;"/><br /><sub>Shao Yu-Lung (Allen)</sub>](http://blog.bestlong.idv.tw/)<br />[πŸ’»](https://github.com/snipe/snipe-it/commits?author=bestlong "Code") | [<img src="https://avatars.githubusercontent.com/u/76475453?v=4" width="110px;"/><br /><sub>Haxatron</sub>](https://github.com/Haxatron)<br />[πŸ’»](https://github.com/snipe/snipe-it/commits?author=Haxatron "Code") | [<img src="https://avatars.githubusercontent.com/u/3842948?v=4" width="110px;"/><br /><sub>Bradley Coudriet</sub>](http://bjcpgd.cias.rit.edu)<br />[πŸ’»](https://github.com/snipe/snipe-it/commits?author=exula "Code") | [<img src="https://avatars.githubusercontent.com/u/21966173?v=4" width="110px;"/><br /><sub>Dalton Durst</sub>](https://daltondur.st)<br />[πŸ’»](https://github.com/snipe/snipe-it/commits?author=UniversalSuperBox "Code") | [<img src="https://avatars.githubusercontent.com/u/48162670?v=4" width="110px;"/><br /><sub>TenOfTens</sub>](https://github.com/TenOfTens)<br />[πŸ’»](https://github.com/snipe/snipe-it/commits?author=TenOfTens "Code") | [<img src="https://avatars.githubusercontent.com/u/917232?v=4" width="110px;"/><br /><sub>Simona Avornicesei</sub>](http://www.avornicesei.com)<br />[⚠️](https://github.com/snipe/snipe-it/commits?author=savornicesei "Tests") |
+| [<img src="https://avatars.githubusercontent.com/u/48162670?v=4" width="110px;"/><br /><sub>TenOfTens</sub>](https://github.com/TenOfTens)<br />[πŸ’»](https://github.com/snipe/snipe-it/commits?author=TenOfTens "Code") | [<img src="https://avatars.githubusercontent.com/u/9415391?v=4" width="110px;"/><br /><sub>waffle</sub>](https://ditisjens.be/)<br />[πŸ’»](https://github.com/snipe/snipe-it/commits?author=insert-waffle "Code") |
<!-- ALL-CONTRIBUTORS-LIST:END -->
This project follows the [all-contributors](https://github.com/kentcdodds/all-contributors) specification. Contributions of any kind welcome!
diff --cc app/Exceptions/Handler.php
index fbd120fe63,3b396ee7c7..2bb8cc9f5e
--- a/app/Exceptions/Handler.php
+++ b/app/Exceptions/Handler.php
@@@ -18,7 -19,15 +18,15 @@@ class Handler extends ExceptionHandle
* @var array
*/
protected $dontReport = [
- JsonException::class
+ \Illuminate\Auth\AuthenticationException::class,
+ \Illuminate\Auth\Access\AuthorizationException::class,
+ \Symfony\Component\HttpKernel\Exception\HttpException::class,
+ \Illuminate\Database\Eloquent\ModelNotFoundException::class,
+ \Illuminate\Session\TokenMismatchException::class,
+ \Illuminate\Validation\ValidationException::class,
+ \Intervention\Image\Exception\NotSupportedException::class,
+ \League\OAuth2\Server\Exception\OAuthServerException::class,
- JsonException::class
++ JsonException::class,
];
/**
@@@ -39,8 -48,7 +47,7 @@@
/**
* Render an exception into an HTTP response.
- *
+ *
- *
* @param \Illuminate\Http\Request $request
* @param \Exception $e
* @return \Illuminate\Http\Response
@@@ -96,26 -104,31 +103,43 @@@
}
- /**
++ /**
+ * Convert an authentication exception into an unauthenticated response.
+ *
+ * @param \Illuminate\Http\Request $request
+ * @param \Illuminate\Auth\AuthenticationException $exception
+ * @return \Illuminate\Http\Response
+ */
+ protected function unauthenticated($request, AuthenticationException $exception)
+ {
+ if ($request->expectsJson()) {
+ return response()->json(['error' => 'Unauthorized or unauthenticated.'], 401);
+ }
+
+ return redirect()->guest('login');
+ }
+
++
+ /**
+ * A list of the inputs that are never flashed for validation exceptions.
+ *
+ * @var array
+ */
+ protected $dontFlash = [
+ 'current_password',
+ 'password',
+ 'password_confirmation',
+ ];
+
/**
- * Convert a validation exception into a JSON response.
+ * Register the exception handling callbacks for the application.
*
- * @param \Illuminate\Http\Request $request
- * @param \Illuminate\Validation\ValidationException $exception
- * @return \Illuminate\Http\JsonResponse
+ * @return void
*/
- protected function invalidJson($request, ValidationException $exception)
+ public function register()
{
- return response()->json(Helper::formatStandardApiResponse('error', null, $exception->errors(), 422));
+ $this->reportable(function (Throwable $e) {
+ //
+ });
}
}
diff --cc app/Http/Controllers/Api/AssetMaintenancesController.php
index 6dcc009fcf,4a07ab86ad..18c205be59
--- a/app/Http/Controllers/Api/AssetMaintenancesController.php
+++ b/app/Http/Controllers/Api/AssetMaintenancesController.php
@@@ -34,7 -33,8 +34,8 @@@ class AssetMaintenancesController exten
*/
public function index(Request $request)
{
+ $this->authorize('view', Asset::class);
- $maintenances = AssetMaintenance::with('asset', 'asset.model','asset.location', 'supplier', 'asset.company', 'admin');
+ $maintenances = AssetMaintenance::with('asset', 'asset.model', 'asset.location', 'supplier', 'asset.company', 'admin');
if ($request->filled('search')) {
$maintenances = $maintenances->TextSearch($request->input('search'));
@@@ -240,11 -245,11 +244,12 @@@
*/
public function show($assetMaintenanceId)
{
+ $this->authorize('view', Asset::class);
$assetMaintenance = AssetMaintenance::findOrFail($assetMaintenanceId);
- if (!Company::isCurrentUserHasAccess($assetMaintenance->asset)) {
+ if (! Company::isCurrentUserHasAccess($assetMaintenance->asset)) {
return response()->json(Helper::formatStandardApiResponse('error', null, 'You cannot view a maintenance for that asset'));
}
+
return (new AssetMaintenancesTransformer())->transformAssetMaintenance($assetMaintenance);
}
diff --cc app/Http/Controllers/Api/AssetsController.php
index b8de5e8f59,6132a16c7f..2b6a7e2b55
--- a/app/Http/Controllers/Api/AssetsController.php
+++ b/app/Http/Controllers/Api/AssetsController.php
@@@ -363,13 -367,12 +363,13 @@@ class AssetsController extends Controll
*/
public function showByTag(Request $request, $tag)
{
- if ($asset = Asset::with('assetstatus')->with('assignedTo')->where('asset_tag',$tag)->first()) {
+ if ($asset = Asset::with('assetstatus')->with('assignedTo')->where('asset_tag', $tag)->first()) {
$this->authorize('view', $asset);
+
return (new AssetsTransformer)->transformAsset($asset, $request);
}
-
return response()->json(Helper::formatStandardApiResponse('error', null, 'Asset not found'), 200);
+
}
/**
@@@ -855,11 -857,16 +855,16 @@@
}
if ($request->has('status_id')) {
- $asset->status_id = $request->input('status_id');
+ $asset->status_id = $request->input('status_id');
}
+ $checkin_at = null;
+ if ($request->filled('checkin_at')) {
+ $checkin_at = $request->input('checkin_at');
+ }
+
if ($asset->save()) {
- event(new CheckoutableCheckedIn($asset, $target, Auth::user(), $request->input('note')));
+ event(new CheckoutableCheckedIn($asset, $target, Auth::user(), $request->input('note'), $checkin_at));
return response()->json(Helper::formatStandardApiResponse('success', ['asset'=> e($asset->asset_tag)], trans('admin/hardware/message.checkin.success')));
}
@@@ -897,14 -883,15 +902,15 @@@
* @since [v4.0]
* @return JsonResponse
*/
- public function audit(Request $request) {
-
+ public function audit(Request $request)
+
+ {
$this->authorize('audit', Asset::class);
- $rules = array(
+ $rules = [
'asset_tag' => 'required',
'location_id' => 'exists:locations,id|nullable|numeric',
- 'next_audit_date' => 'date|nullable'
- );
+ 'next_audit_date' => 'date|nullable',
+ ];
$validator = Validator::make($request->all(), $rules);
if ($validator->fails()) {
diff --cc app/Http/Controllers/Api/CategoriesController.php
index b1e36b29e0,5004490676..9310562866
--- a/app/Http/Controllers/Api/CategoriesController.php
+++ b/app/Http/Controllers/Api/CategoriesController.php
@@@ -132,10 -133,11 +134,11 @@@ class CategoriesController extends Cont
);
}
$category->delete();
- return response()->json(Helper::formatStandardApiResponse('success', null, trans('admin/categories/message.delete.success')));
+ return response()->json(Helper::formatStandardApiResponse('success', null, trans('admin/categories/message.delete.success')));
}
+
/**
* Gets a paginated collection for the select2 menus
*
diff --cc app/Http/Controllers/Api/DepartmentsController.php
index 9c648e635b,e48a3df839..314de2aa5c
--- a/app/Http/Controllers/Api/DepartmentsController.php
+++ b/app/Http/Controllers/Api/DepartmentsController.php
@@@ -134,6 -132,8 +134,7 @@@ class DepartmentsController extends Con
return response()->json(Helper::formatStandardApiResponse('error', null, $department->getErrors()));
}
+
-
/**
* Validates and deletes selected department.
*
diff --cc app/Http/Controllers/Api/LicensesController.php
index d03a45f029,2371f4bdac..5a4c7d90d3
--- a/app/Http/Controllers/Api/LicensesController.php
+++ b/app/Http/Controllers/Api/LicensesController.php
@@@ -92,6 -82,11 +92,10 @@@ class LicensesController extends Contro
$licenses = $licenses->TextSearch($request->input('search'));
}
+ if ($request->input('deleted')=='true') {
+ $licenses->onlyTrashed();
+ }
+
-
// Set the offset to the API call's offset, unless the offset is higher than the actual count of items in which
// case we override with the actual count, so we should return 0 items.
$offset = (($licenses) && ($request->get('offset') > $licenses->count())) ? $licenses->count() : $request->get('offset', 0);
diff --cc app/Http/Controllers/Api/LocationsController.php
index 43be34a27f,ec91310e6f..fa16f8dbb3
--- a/app/Http/Controllers/Api/LocationsController.php
+++ b/app/Http/Controllers/Api/LocationsController.php
@@@ -73,9 -75,9 +73,10 @@@ class LocationsController extends Contr
break;
}
+
$total = $locations->count();
$locations = $locations->skip($offset)->take($limit)->get();
+
return (new LocationsTransformer)->transformLocations($locations, $total);
}
diff --cc app/Http/Controllers/Api/ManufacturersController.php
index 5392c1d217,5fa4560fe6..b1a411fc58
--- a/app/Http/Controllers/Api/ManufacturersController.php
+++ b/app/Http/Controllers/Api/ManufacturersController.php
@@@ -131,11 -133,15 +131,11 @@@ class ManufacturersController extends C
if ($manufacturer->isDeletable()) {
$manufacturer->delete();
-
- return response()->json(Helper::formatStandardApiResponse('success', null, trans('admin/manufacturers/message.delete.success')));
+ return response()->json(Helper::formatStandardApiResponse('success', null, trans('admin/manufacturers/message.delete.success')));
}
- return response()->json(Helper::formatStandardApiResponse('error', null, trans('admin/manufacturers/message.assoc_users')));
+ return response()->json(Helper::formatStandardApiResponse('error', null, trans('admin/manufacturers/message.assoc_users')));
+
-
-
-
-
}
/**
diff --cc app/Http/Controllers/Api/SuppliersController.php
index e5668b6baa,d04bb61f03..40ff9e8bd8
--- a/app/Http/Controllers/Api/SuppliersController.php
+++ b/app/Http/Controllers/Api/SuppliersController.php
@@@ -124,11 -123,12 +125,12 @@@ class SuppliersController extends Contr
public function destroy($id)
{
$this->authorize('delete', Supplier::class);
- $supplier = Supplier::with('asset_maintenances', 'assets', 'licenses')->withCount('asset_maintenances as asset_maintenances_count','assets as assets_count', 'licenses as licenses_count')->findOrFail($id);
+ $supplier = Supplier::with('asset_maintenances', 'assets', 'licenses')->withCount('asset_maintenances as asset_maintenances_count', 'assets as assets_count', 'licenses as licenses_count')->findOrFail($id);
$this->authorize('delete', $supplier);
+
if ($supplier->assets_count > 0) {
- return response()->json(Helper::formatStandardApiResponse('error', null, trans('admin/suppliers/message.delete.assoc_assets', ['asset_count' => (int) $supplier->assets_count])));
+ return response()->json(Helper::formatStandardApiResponse('error', null, trans('admin/suppliers/message.delete.assoc_assets', ['asset_count' => (int) $supplier->assets_count])));
}
if ($supplier->asset_maintenances_count > 0) {
diff --cc app/Http/Controllers/AssetModelsController.php
index f431a17369,ef16eaebb8..9a7c1407bc
--- a/app/Http/Controllers/AssetModelsController.php
+++ b/app/Http/Controllers/AssetModelsController.php
@@@ -121,8 -119,10 +121,9 @@@ class AssetModelsController extends Con
}
return redirect()->route('models.index')->with('error', trans('admin/models/message.does_not_exist'));
-
}
+
/**
* Validates and processes form data from the edit
* Asset Model form based on the model ID passed.
@@@ -228,13 -229,13 +229,14 @@@
if (isset($model->id)) {
$model->restore();
+
return redirect()->route('models.index')->with('success', trans('admin/models/message.restore.success'));
}
-
return redirect()->back()->with('error', trans('admin/models/message.not_found'));
+
}
+
/**
* Get the model information to present to the model view page
*
@@@ -282,19 -283,23 +284,22 @@@
->with('clone_model', $model_to_clone);
}
+
/**
- * Get the custom fields form
- *
- * @author [B. Wetherington] [<[email protected]>]
- * @since [v2.0]
- * @param int $modelId
- * @return View
- */
+ * Get the custom fields form
+ *
+ * @author [B. Wetherington] [<[email protected]>]
+ * @since [v2.0]
+ * @param int $modelId
+ * @return View
+ */
public function getCustomFields($modelId)
{
- return view("models.custom_fields_form")->with("model", AssetModel::find($modelId));
+ return view('models.custom_fields_form')->with('model', AssetModel::find($modelId));
}
+
+
-
/**
* Returns a view that allows the user to bulk edit model attrbutes
*
@@@ -335,8 -344,11 +340,10 @@@
return redirect()->route('models.index')
->with('error', 'You must select at least one model to edit.');
-
}
+
+
/**
* Returns a view that allows the user to bulk edit model attrbutes
*
@@@ -346,25 -358,28 +353,27 @@@
*/
public function postBulkEditSave(Request $request)
{
-
$models_raw_array = $request->input('ids');
- $update_array = array();
+ $update_array = [];
+
- if (($request->filled('manufacturer_id') && ($request->input('manufacturer_id')!='NC'))) {
+ if (($request->filled('manufacturer_id') && ($request->input('manufacturer_id') != 'NC'))) {
$update_array['manufacturer_id'] = $request->input('manufacturer_id');
}
- if (($request->filled('category_id') && ($request->input('category_id')!='NC'))) {
+ if (($request->filled('category_id') && ($request->input('category_id') != 'NC'))) {
$update_array['category_id'] = $request->input('category_id');
}
- if ($request->input('fieldset_id')!='NC') {
+ if ($request->input('fieldset_id') != 'NC') {
$update_array['fieldset_id'] = $request->input('fieldset_id');
}
- if ($request->input('depreciation_id')!='NC') {
+ if ($request->input('depreciation_id') != 'NC') {
$update_array['depreciation_id'] = $request->input('depreciation_id');
}
-
+
if (count($update_array) > 0) {
AssetModel::whereIn('id', $models_raw_array)->update($update_array);
+
return redirect()->route('models.index')
->with('success', trans('admin/models/message.bulkedit.success'));
}
diff --cc app/Http/Controllers/Auth/LoginController.php
index 3e256c564e,5c6524bf65..7b55539ccd
--- a/app/Http/Controllers/Auth/LoginController.php
+++ b/app/Http/Controllers/Auth/LoginController.php
@@@ -402,14 -363,16 +403,15 @@@ class LoginController extends Controlle
if (Google2FA::verifyKey($user->two_factor_secret, $secret)) {
$user->two_factor_enrolled = 1;
$user->save();
- $request->session()->put('2fa_authed', 'true');
+ $request->session()->put('2fa_authed', $user->id);
+
return redirect()->route('home')->with('success', 'You are logged in!');
}
return redirect()->route('two-factor')->with('error', trans('auth/message.two_factor.invalid_code'));
-
-
}
+
/**
* Logout page.
*
diff --cc app/Http/Controllers/CustomFieldsController.php
index 8e29cba748,d539b636c3..da4bd08550
--- a/app/Http/Controllers/CustomFieldsController.php
+++ b/app/Http/Controllers/CustomFieldsController.php
@@@ -48,11 -50,14 +48,12 @@@ class CustomFieldsController extends Co
* @return Redirect
* @throws \Illuminate\Auth\Access\AuthorizationException
*/
-
public function show()
{
- return redirect()->route("fields.index");
-
+ return redirect()->route('fields.index');
}
+
/**
* Returns a view with a form to create a new custom field.
*
@@@ -96,10 -101,11 +97,11 @@@
"user_id" => Auth::id()
]);
+
- if ($request->filled("custom_format")) {
- $field->format = e($request->get("custom_format"));
+ if ($request->filled('custom_format')) {
+ $field->format = e($request->get('custom_format'));
} else {
- $field->format = e($request->get("format"));
+ $field->format = e($request->get('format'));
}
if ($field->save()) {
@@@ -125,12 -133,23 +127,23 @@@
$this->authorize('update', $field);
+ // Check that the field exists - this is mostly related to the demo, where we
+ // rewrite the data every x minutes, so it's possible someone might be disassociating
+ // a field from a fieldset just as we're wiping the database
+ if (($field) && ($fieldset_id)) {
+
- if ($field->fieldset()->detach($fieldset_id)) {
- return redirect()->route('fieldsets.show', ['fieldset' => $fieldset_id])
- ->with("success", trans('admin/custom_fields/message.field.delete.success'));
+ if ($field->fieldset()->detach($fieldset_id)) {
+ return redirect()->route('fieldsets.show', ['fieldset' => $fieldset_id])
+ ->with('success', trans('admin/custom_fields/message.field.delete.success'));
+ } else {
+ return redirect()->back()->withErrors(['message' => "Field is in use and cannot be deleted."]);
+ }
+
}
- return redirect()->back()->withErrors(['message' => 'Field is in-use']);
+ return redirect()->back()->withErrors(['message' => "Error deleting field from fieldset"]);
+
+
}
/**
@@@ -154,9 -174,10 +167,10 @@@
->with("success", trans('admin/custom_fields/message.field.delete.success'));
}
- return redirect()->back()->withErrors(['message' => "Field does not exist"]);
+ return redirect()->back()->withErrors(['message' => 'Field does not exist']);
}
+
/**
* Return a view to edit a custom field
*
diff --cc app/Http/Controllers/SettingsController.php
index 27fd8236ad,91fa4d569d..852212ef3c
--- a/app/Http/Controllers/SettingsController.php
+++ b/app/Http/Controllers/SettingsController.php
@@@ -419,7 -422,8 +420,8 @@@ class SettingsController extends Contro
$setting->brand = 1;
}
+
- $setting = $request->handleImages($setting,600,'email_logo','', 'email_logo');
+ $setting = $request->handleImages($setting, 600, 'email_logo', '', 'email_logo');
if ('1' == $request->input('clear_email_logo')) {
@@@ -615,8 -622,28 +618,28 @@@
return redirect()->to('admin')->with('error', trans('admin/settings/message.update.error'));
}
+ // Check if the audit interval has changed - if it has, we want to update ALL of the assets audit dates
+ if ($request->input('audit_interval') != $setting->audit_interval) {
+
+ // Be careful - this could be a negative number
+ $audit_diff_months = ((int)$request->input('audit_interval') - (int)($setting->audit_interval));
+
+ // Grab all of the assets that have an existing next_audit_date
+ $assets = Asset::whereNotNull('next_audit_date')->get();
+
+ // Update all of the assets' next_audit_date values
+ foreach ($assets as $asset) {
+
+ if ($asset->next_audit_date != '') {
+ $old_next_audit = new \DateTime($asset->next_audit_date);
+ $asset->next_audit_date = $old_next_audit->modify($audit_diff_months.' month')->format('Y-m-d');
+ $asset->forceSave();
+ }
+ }
- }
++ }
+
- $alert_email = rtrim($request->input('alert_email'), ',');
- $alert_email = trim($alert_email);
+ $alert_email = rtrim($request->input('alert_email'), ',');
+ $alert_email = trim($alert_email);
$admin_cc_email = rtrim($request->input('admin_cc_email'), ',');
$admin_cc_email = trim($admin_cc_email);
@@@ -1024,10 -1051,7 +1047,9 @@@
// Skip dotfiles like .gitignore and .DS_STORE
if ((substr(basename($backup_files[$f]), 0, 1) != '.')) {
+ //$lastmodified = Carbon::parse(Storage::lastModified($backup_files[$f]))->toDatetimeString();
+ $file_timestamp = Storage::lastModified($backup_files[$f]);
-
$files_raw[] = [
'filename' => basename($backup_files[$f]),
'filesize' => Setting::fileSizeConvert(Storage::size($backup_files[$f])),
diff --cc app/Http/Transformers/ActionlogsTransformer.php
index 8e32ac705a,c1bf4c9c3c..7959157105
--- a/app/Http/Transformers/ActionlogsTransformer.php
+++ b/app/Http/Transformers/ActionlogsTransformer.php
@@@ -34,9 -33,14 +34,13 @@@ class ActionlogsTransforme
if ($meta_array) {
foreach ($meta_array as $key => $value) {
foreach ($value as $meta_key => $meta_value) {
-
if (is_array($meta_value)) {
foreach ($meta_value as $meta_value_key => $meta_value_value) {
- $clean_meta[$key][$meta_value_key] = e($meta_value_value);
+ if (is_scalar($meta_value_value)) {
+ $clean_meta[$key][$meta_value_key] = e($meta_value_value);
+ } else {
+ $clean_meta[$key][$meta_value_key] = 'invalid scalar: '.print_r($meta_value_value, true);
+ }
}
} else {
diff --cc app/Http/Transformers/LicensesTransformer.php
index 56492ba45c,ee2fe3041e..3fb2a8943b
--- a/app/Http/Transformers/LicensesTransformer.php
+++ b/app/Http/Transformers/LicensesTransformer.php
@@@ -42,11 -41,13 +42,13 @@@ class LicensesTransforme
'license_email' => e($license->license_email),
'reassignable' => ($license->reassignable == 1) ? true : false,
'maintained' => ($license->maintained == 1) ? true : false,
- 'supplier' => ($license->supplier) ? ['id' => (int) $license->supplier->id,'name'=> e($license->supplier->name)] : null,
- 'category' => ($license->category) ? ['id' => (int) $license->category->id,'name'=> e($license->category->name)] : null,
+ 'supplier' => ($license->supplier) ? ['id' => (int) $license->supplier->id, 'name'=> e($license->supplier->name)] : null,
+ 'category' => ($license->category) ? ['id' => (int) $license->category->id, 'name'=> e($license->category->name)] : null,
'created_at' => Helper::getFormattedDateObject($license->created_at, 'datetime'),
'updated_at' => Helper::getFormattedDateObject($license->updated_at, 'datetime'),
+ 'deleted_at' => Helper::getFormattedDateObject($license->deleted_at, 'datetime'),
'user_can_checkout' => (bool) ($license->free_seats_count > 0),
+
];
$permissions_array['available_actions'] = [
diff --cc app/Models/Loggable.php
index 988eda3aa4,d8b3e7f9a0..3609298ac7
--- a/app/Models/Loggable.php
+++ b/app/Models/Loggable.php
@@@ -108,11 -109,13 +108,12 @@@ trait Loggabl
$asset->increment('checkin_counter', 1);
}
}
-
}
+
$log->location_id = null;
$log->note = $note;
- $log->action_date= $action_date;
+ $log->action_date = $action_date;
if (Auth::user()) {
$log->user_id = Auth::user()->id;
diff --cc app/Providers/AuthServiceProvider.php
index 31a328abfe,6352e65dcb..7148e03f49
--- a/app/Providers/AuthServiceProvider.php
+++ b/app/Providers/AuthServiceProvider.php
@@@ -162,8 -169,22 +164,22 @@@ class AuthServiceProvider extends Servi
|| $user->can('view', Company::class)
|| $user->can('view', Manufacturer::class)
|| $user->can('view', CustomField::class)
- || $user->can('view', CustomFieldset::class)
- || $user->can('view', Depreciation::class);
+ || $user->can('view', CustomFieldset::class)
+ || $user->can('view', Depreciation::class);
});
+
+
+ // This determines whether or not an API user should be able to get the selectlists.
+ // This can seem a little confusing, since view properties may not have been granted
+ // to the logged in API user, but creating assets, licenses, etc won't work
+ // if the user can't view and interact with the select lists.
+ Gate::define('view.selectlists', function ($user) {
+ return $user->can(['create','update'], Asset::class)
+ || $user->can(['create','update'], License::class)
+ || $user->can(['create','update'], Component::class)
+ || $user->can(['create','update'], Consumable::class)
+ || $user->can(['create','update'], Accessory::class)
+ || $user->can(['create','update'], User::class);
+ });
}
}
diff --cc database/migrations/2015_11_08_222305_add_ldap_fields_to_settings.php
index d52191f3d0,f117dc2f76..171258f27c
--- a/database/migrations/2015_11_08_222305_add_ldap_fields_to_settings.php
+++ b/database/migrations/2015_11_08_222305_add_ldap_fields_to_settings.php
@@@ -1,57 -1,60 +1,57 @@@
<?php
-use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
-class AddLdapFieldsToSettings extends Migration {
-
- /**
- * Run the migrations.
- *
- * @return void
- */
- public function up()
- {
- Schema::table('settings', function(Blueprint $table)
- {
- $table->string('ldap_enabled')->nullable()->default(NULL);
- $table->string('ldap_server')->nullable()->default(NULL);
- $table->string('ldap_uname')->nullable()->default(NULL);
- $table->longText('ldap_pword')->nullable()->default(NULL);
- $table->string('ldap_basedn')->nullable()->default(NULL);
- $table->string('ldap_filter')->nullable()->default('cn=*');
- $table->string('ldap_username_field')->nullable()->default('samaccountname');
- $table->string('ldap_lname_field')->nullable()->default('sn');
- $table->string('ldap_fname_field')->nullable()->default('givenname');
+class AddLdapFieldsToSettings extends Migration
+{
+ /**
+ * Run the migrations.
+ *
+ * @return void
+ */
+ public function up()
+ {
+ Schema::table('settings', function (Blueprint $table) {
+ $table->string('ldap_enabled')->nullable()->default(null);
+ $table->string('ldap_server')->nullable()->default(null);
+ $table->string('ldap_uname')->nullable()->default(null);
+ $table->longText('ldap_pword')->nullable()->default(null);
+ $table->string('ldap_basedn')->nullable()->default(null);
+ $table->string('ldap_filter')->nullable()->default('cn=*');
+ $table->string('ldap_username_field')->nullable()->default('samaccountname');
+ $table->string('ldap_lname_field')->nullable()->default('sn');
+ $table->string('ldap_fname_field')->nullable()->default('givenname');
- $table->string('ldap_auth_filter_query')->nullable()->default('uid=samaccountname');
+ $table->string('ldap_auth_filter_query')->nullable()->default('uid=');
- $table->integer('ldap_version')->nullable()->default(3);
- $table->string('ldap_active_flag')->nullable()->default(NULL);
- $table->string('ldap_emp_num')->nullable()->default(NULL);
- $table->string('ldap_email')->nullable()->default(NULL);
- });
- }
-
- /**
- * Reverse the migrations.
- *
- * @return void
- */
- public function down()
- {
- Schema::table('settings', function(Blueprint $table)
- {
- $table->dropColumn('ldap_enabled');
- $table->dropColumn('ldap_server');
- $table->dropColumn('ldap_uname');
- $table->dropColumn('ldap_pword');
- $table->dropColumn('ldap_basedn');
- $table->dropColumn('ldap_filter');
- $table->dropColumn('ldap_username_field');
- $table->dropColumn('ldap_lname_field');
- $table->dropColumn('ldap_fname_field');
- $table->dropColumn('ldap_auth_filter_query');
- $table->dropColumn('ldap_version');
- $table->dropColumn('ldap_active_flag');
- $table->dropColumn('ldap_emp_num');
- $table->dropColumn('ldap_email');
- });
- }
+ $table->integer('ldap_version')->nullable()->default(3);
+ $table->string('ldap_active_flag')->nullable()->default(null);
+ $table->string('ldap_emp_num')->nullable()->default(null);
+ $table->string('ldap_email')->nullable()->default(null);
+ });
+ }
+ /**
+ * Reverse the migrations.
+ *
+ * @return void
+ */
+ public function down()
+ {
+ Schema::table('settings', function (Blueprint $table) {
+ $table->dropColumn('ldap_enabled');
+ $table->dropColumn('ldap_server');
+ $table->dropColumn('ldap_uname');
+ $table->dropColumn('ldap_pword');
+ $table->dropColumn('ldap_basedn');
+ $table->dropColumn('ldap_filter');
+ $table->dropColumn('ldap_username_field');
+ $table->dropColumn('ldap_lname_field');
+ $table->dropColumn('ldap_fname_field');
+ $table->dropColumn('ldap_auth_filter_query');
+ $table->dropColumn('ldap_version');
+ $table->dropColumn('ldap_active_flag');
+ $table->dropColumn('ldap_emp_num');
+ $table->dropColumn('ldap_email');
+ });
+ }
}