Skip to content
This repository has been archived by the owner on Nov 2, 2020. It is now read-only.

Commit

Permalink
revert(Http): Remove Request::getUserAgent()
Browse files Browse the repository at this point in the history
Remove Dependency of `piwik/device-detector`
  • Loading branch information
Rhilip committed Mar 17, 2019
1 parent 671a551 commit ada223c
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 146 deletions.
2 changes: 1 addition & 1 deletion apps/models/form/UserLoginForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ public function createUserSession()
'VALUES (:uid,:sid,INET6_ATON(:login_ip),:ua, NOW())')->bindParams([
'uid' => $userId, 'sid' => $userSessionId,
'login_ip' => app()->request->getClientIp(),
'ua' => app()->request->getUserAgent()
'ua' => app()->request->header('user-agent')
])->execute();

// Add this session id in Redis Cache
Expand Down
1 change: 0 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
"psr/log": "^1.1",
"robthree/twofactorauth": "^1.6",
"swiftmailer/swiftmailer": "^6.1",
"piwik/device-detector": "^3.11",
"league/plates": "^3.3",
"siriusphp/validation": "^2.2",
"phpmailer/phpmailer": "^6.0"
Expand Down
119 changes: 1 addition & 118 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 0 additions & 26 deletions framework/Http/BaseRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
use Rid\Utils\HeaderUtils;
use Rid\Utils\IpUtils;

use DeviceDetector\DeviceDetector;

/**
* Request组件基类
Expand Down Expand Up @@ -209,31 +208,6 @@ protected function scheme()
return $this->server('request_scheme') ?: $this->header('scheme');
}

/**
* Return the client Raw User-Agent
*
* This method can read the client User Agent info form the "User-Agent" header
* when set `$detector=true` ,it will return the DeviceDetector object to
* help user quick detects devices (desktop, tablet, mobile, tv, cars, console, etc.),
* clients (browsers, feed readers, media players, PIMs, ...), operating systems,
* brands and models.
*
* @see https://github.com/matomo-org/device-detector
*
* @param bool $detector
* @return DeviceDetector|string
*/
public function getUserAgent($detector = false)
{
$userAgent = $this->header('user-agent') ?? '';
if ($detector) {
$dd = new DeviceDetector($userAgent);
$dd->parse();
return $dd;
}
return $userAgent;
}

/**
* Returns the client IP address.
*
Expand Down

0 comments on commit ada223c

Please sign in to comment.