A free open source IT asset/license management system
Added user agent to log method
snipe40052e99a798
diff --git a/app/Models/Actionlog.php b/app/Models/Actionlog.phpindex 9f87ffd8c2..de00eefeb7 100755--- a/app/Models/Actionlog.php+++ b/app/Models/Actionlog.php@@ -266,6 +266,9 @@ class Actionlog extends SnipeModelpublic function logaction($actiontype){$this->action_type = $actiontype;+ $this->remote_ip = request()->ip();+ $this->user_agent = request()->header('User-Agent');+ $this->action_source = $this->determineActionSource();if ($this->save()) {return true;@@ -330,4 +333,22 @@ class Actionlog extends SnipeModel->orderBy('created_at', 'asc')->get();}++ public function determineActionSource() {++ // This is an API call+ if (((request()->header('content-type') && (request()->header('accept'))=='application/json'))+ && (starts_with(request()->header('authorization'), 'Bearer '))) {+ return 'api';+ }++ // This is probably NOT an API call+ if (request()->filled('_token')) {+ return 'gui';+ }++ // We're not sure, probably cli+ return 'cli/unknown';++ }}