mirror of
https://github.com/snipe/snipe-it.git
synced 2024-12-24 13:14:07 -08:00
Set a user_id of -1 if there isn't a logged in user. This fixes the CLI importer, and opens the door in the future for some sort of virtual importer user... which may fix other issues the importer currently has (#2775)
This commit is contained in:
parent
0a0006c68c
commit
85af8e46e3
|
@ -371,25 +371,25 @@ class ReportsController extends Controller
|
|||
if($activity->target) {
|
||||
$activity_target = '<a href="'.route('view/hardware', $activity->target_id).'">'.$activity->target->showAssetName().'</a>';
|
||||
} else {
|
||||
$activity_target = "Unknown Item";
|
||||
$activity_target = "";
|
||||
}
|
||||
} elseif ( $activity->target_type === "App\Models\User") {
|
||||
if($activity->target()) {
|
||||
$activity_target = '<a href="'.route('view/user', $activity->target_id).'">'.$activity->target->fullName().'</a>';
|
||||
} else {
|
||||
$activity_target = 'Unknown User';
|
||||
$activity_target = '';
|
||||
}
|
||||
} elseif ($activity->action_type=='requested') {
|
||||
if ($activity->user) {
|
||||
$activity_target = '<a href="'.route('view/user', $activity->user_id).'">'.$activity->user->fullName().'</a>';
|
||||
} else {
|
||||
$activity_target = 'Unknown User';
|
||||
$activity_target = '';
|
||||
}
|
||||
} else {
|
||||
if($activity->target) {
|
||||
$activity_target = $activity->target->id;
|
||||
} else {
|
||||
$activity_target = "Unknown";
|
||||
$activity_target = "";
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -83,11 +83,15 @@ trait Loggable
|
|||
|
||||
/**
|
||||
* @author Daniel Meltzer <parallelgrapefruit@gmail.com
|
||||
* @since [v3.4]
|
||||
* @since [v3.5]
|
||||
* @return \App\Models\Actionlog
|
||||
*/
|
||||
public function logCreate($note = null)
|
||||
{
|
||||
$user_id = -1;
|
||||
if (Auth::user()) {
|
||||
$user_id = Auth::user()->id;
|
||||
}
|
||||
$log = new Actionlog;
|
||||
if (static::class == LicenseSeat::class) {
|
||||
$log->item_type = License::class;
|
||||
|
@ -98,9 +102,9 @@ trait Loggable
|
|||
}
|
||||
$log->location_id = null;
|
||||
$log->note = $note;
|
||||
$log->user_id = Auth::user()->id;
|
||||
$log->user_id = $user_id;
|
||||
$log->logaction('created');
|
||||
|
||||
$log->save();
|
||||
return $log;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue