mirror of
https://github.com/snipe/snipe-it.git
synced 2025-01-26 05:01:06 -08:00
Added user agent to log method
Signed-off-by: snipe <snipe@snipe.net>
This commit is contained in:
parent
70303c2b2d
commit
40052e99a7
|
@ -266,6 +266,9 @@ class Actionlog extends SnipeModel
|
|||
public 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';
|
||||
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue