Skip to content

Commit ccff234

Browse files
committed
added login info from browscap
1 parent 194b96b commit ccff234

1 file changed

Lines changed: 44 additions & 18 deletions

File tree

src/Admin/src/Service/AdminLoginService.php

Lines changed: 44 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -111,24 +111,50 @@ private function logAdminVisit(array $serverParams, string $name, SuccessFailure
111111
$continent = $this->locationService->getContinent($ipAddress)->getName();
112112
$organization = $this->locationService->getOrganization($ipAddress)->getName();
113113

114-
$adminLogin = (new AdminLogin())
115-
->setAdminIp($this->locationService->obfuscateIpAddress($ipAddress))
116-
->setContinent($continent)
117-
->setCountry($country)
118-
->setOrganization($organization)
119-
->setDeviceType(null)
120-
->setDeviceBrand(null)
121-
->setDeviceModel(null)
122-
->setIsMobile(YesNoEnum::No)
123-
->setOsName(null)
124-
->setOsVersion(null)
125-
->setOsPlatform(null)
126-
->setClientType(null)
127-
->setClientName(null)
128-
->setClientEngine(null)
129-
->setClientVersion(null)
130-
->setLoginStatus($status)
131-
->setIdentity($name);
114+
//check browscap availability
115+
if (ini_get('browscap')) {
116+
//call browscap
117+
$browser = get_browser($_SERVER['HTTP_USER_AGENT'], true);
118+
119+
//map browscap to AdminLogin
120+
$adminLogin = (new AdminLogin())
121+
->setAdminIp($this->locationService->obfuscateIpAddress($ipAddress))
122+
->setContinent($continent)
123+
->setCountry($country)
124+
->setOrganization($organization)
125+
->setDeviceType($browser['device_type'])
126+
->setDeviceBrand($browser['device_name'])
127+
->setDeviceModel(null)
128+
->setIsMobile($browser['ismobiledevice'] ? YesNoEnum::Yes : YesNoEnum::No)
129+
->setOsName($browser['platform_description'])
130+
->setOsVersion($browser['platform_version'])
131+
->setOsPlatform($browser['platform'])
132+
->setClientType($browser['browser_type'])
133+
->setClientName($browser['browser'])
134+
->setClientEngine($browser['renderingengine_name'])
135+
->setClientVersion(null)
136+
->setLoginStatus($status)
137+
->setIdentity($name);
138+
} else {
139+
$adminLogin = (new AdminLogin())
140+
->setAdminIp($this->locationService->obfuscateIpAddress($ipAddress))
141+
->setContinent($continent)
142+
->setCountry($country)
143+
->setOrganization($organization)
144+
->setDeviceType(null)
145+
->setDeviceBrand(null)
146+
->setDeviceModel(null)
147+
->setIsMobile(YesNoEnum::No)
148+
->setOsName(null)
149+
->setOsVersion(null)
150+
->setOsPlatform(null)
151+
->setClientType(null)
152+
->setClientName(null)
153+
->setClientEngine(null)
154+
->setClientVersion(null)
155+
->setLoginStatus($status)
156+
->setIdentity($name);
157+
}
132158

133159
$this->adminLoginRepository->saveResource($adminLogin);
134160

0 commit comments

Comments
 (0)