Skip to content

Commit 04ac07d

Browse files
authored
Merge pull request #424 from dotkernel/issue-423
Issue #423: Upgraded mezzio-oauth2 to v3.0.1
2 parents 7e04718 + cdd18e9 commit 04ac07d

22 files changed

Lines changed: 263 additions & 181 deletions

bin/composer-post-install-script.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,12 @@ function getEnvironment(): string
5454
],
5555
[
5656
'source' => 'vendor/dotkernel/dot-mail/config/mail.global.php.dist',
57-
'destination' => 'config/autoload/mail.global.php',
57+
'destination' => 'config/autoload/mail.local.php',
58+
'environment' => [ENVIRONMENT_DEVELOPMENT, ENVIRONMENT_PRODUCTION],
59+
],
60+
[
61+
'source' => 'vendor/dotkernel/dot-mail/config/mail.global.php.dist',
62+
'destination' => 'config/autoload/mail.local.php.dist',
5863
'environment' => [ENVIRONMENT_DEVELOPMENT, ENVIRONMENT_PRODUCTION],
5964
],
6065
];

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
"laminas/laminas-component-installer": "^3.7.0",
4848
"laminas/laminas-config-aggregator": "^1.19.0",
4949
"mezzio/mezzio": "^3.26.0",
50-
"mezzio/mezzio-authentication-oauth2": "^2.13.0",
50+
"mezzio/mezzio-authentication-oauth2": "^3.0.1",
5151
"mezzio/mezzio-authorization-rbac": "^1.10.0",
5252
"mezzio/mezzio-cors": "^1.15.0",
5353
"mezzio/mezzio-fastroute": "^3.14.0",

src/Admin/src/Service/AdminLoginService.php

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,11 @@ public function getAdminLogins(array $params): array
5757
'login.osVersion',
5858
'login.clientType',
5959
'login.clientName',
60-
'login.isCrawler',
60+
'login.deviceBrand',
61+
'login.deviceModel',
62+
'login.osPlatform',
63+
'login.clientEngine',
64+
'login.clientVersion',
6165
'login.loginStatus',
6266
'login.identity',
6367
'login.created',
@@ -75,7 +79,7 @@ public function getAdminLogins(array $params): array
7579
}
7680

7781
/**
78-
* @param non-empty-array<non-empty-string, mixed> $serverParams
82+
* @param array{HTTP_X_FORWARDED_FOR?: string, HTTP_CLIENT_IP?: string, REMOTE_ADDR: string} $serverParams
7983
* @throws Exception
8084
*/
8185
public function logFailedLogin(array $serverParams, string $name): AdminLogin
@@ -84,7 +88,7 @@ public function logFailedLogin(array $serverParams, string $name): AdminLogin
8488
}
8589

8690
/**
87-
* @param non-empty-array<non-empty-string, mixed> $serverParams
91+
* @param array{HTTP_X_FORWARDED_FOR?: string, HTTP_CLIENT_IP?: string, REMOTE_ADDR: string} $serverParams
8892
* @throws Exception
8993
*/
9094
public function logSuccessfulLogin(array $serverParams, string $name): AdminLogin
@@ -93,7 +97,7 @@ public function logSuccessfulLogin(array $serverParams, string $name): AdminLogi
9397
}
9498

9599
/**
96-
* @param non-empty-array<non-empty-string, mixed> $serverParams
100+
* @param array{HTTP_X_FORWARDED_FOR?: string, HTTP_CLIENT_IP?: string, REMOTE_ADDR: string} $serverParams
97101
* @throws Exception
98102
*/
99103
private function logAdminVisit(array $serverParams, string $name, SuccessFailureEnum $status): AdminLogin
@@ -111,7 +115,8 @@ private function logAdminVisit(array $serverParams, string $name, SuccessFailure
111115
*/
112116
$browser = new stdClass();
113117
if (ini_get('browscap')) {
114-
$browser = get_browser($_SERVER['HTTP_USER_AGENT']);
118+
$result = get_browser($_SERVER['HTTP_USER_AGENT']);
119+
$browser = $result instanceof stdClass ? $result : $browser;
115120
}
116121

117122
$adminLogin = (new AdminLogin())
@@ -128,7 +133,11 @@ private function logAdminVisit(array $serverParams, string $name, SuccessFailure
128133
->setClientType(! empty($browser->browser_type) ? $browser->browser_type : null)
129134
->setClientName(! empty($browser->browser) ? $browser->browser : null)
130135
->setLoginStatus($status)
131-
->setIsCrawler(! empty($browser->crawler) ? YesNoEnum::Yes : YesNoEnum::No)
136+
->setDeviceBrand(! empty($browser->device_brand) ? $browser->device_brand : null)
137+
->setDeviceBrand(! empty($browser->device_model) ? $browser->device_model : null)
138+
->setDeviceBrand(! empty($browser->platform_version) ? $browser->platform_version : null)
139+
->setDeviceBrand(! empty($browser->browser_engine) ? $browser->browser_engine : null)
140+
->setDeviceBrand(! empty($browser->browser_version) ? $browser->browser_version : null)
132141
->setIdentity($name);
133142

134143
$this->adminLoginRepository->saveResource($adminLogin);

src/Admin/templates/admin/list-admin-login.html.twig

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,20 @@
9191
<th class="column-login-clientName">
9292
{{ sortableColumn('admin::list-admin-login', {}, pagination.queryParams, 'login.clientName', 'Client Name') }}
9393
</th>
94-
<th class="column-login-isCrawler">
95-
{{ sortableColumn('admin::list-admin-login', {}, pagination.queryParams, 'login.isCrawler', 'Is Crawler') }}
94+
<th class="column-login-deviceBrand">
95+
{{ sortableColumn('admin::list-admin-login', {}, pagination.queryParams, 'login.deviceBrand', 'Device Brand') }}
96+
</th>
97+
<th class="column-login-deviceModel">
98+
{{ sortableColumn('admin::list-admin-login', {}, pagination.queryParams, 'login.deviceModel', 'Device Model') }}
99+
</th>
100+
<th class="column-login-osPlatform">
101+
{{ sortableColumn('admin::list-admin-login', {}, pagination.queryParams, 'login.osPlatform', 'Os Platform') }}
102+
</th>
103+
<th class="column-login-clientEngine">
104+
{{ sortableColumn('admin::list-admin-login', {}, pagination.queryParams, 'login.clientEngine', 'Client Engine') }}
105+
</th>
106+
<th class="column-login-clientVersion">
107+
{{ sortableColumn('admin::list-admin-login', {}, pagination.queryParams, 'login.clientVersion', 'Client Version') }}
96108
</th>
97109
<th class="column-login-created">
98110
{{ sortableColumn('admin::list-admin-login', {}, pagination.queryParams, 'login.created', 'Created') }}
@@ -126,13 +138,11 @@
126138
<td class="column-login-osVersion">{{ login.osVersion }}</td>
127139
<td class="column-login-clientType">{{ login.clientType }}</td>
128140
<td class="column-login-clientName">{{ login.clientName }}</td>
129-
<td class="column-login-isCrawler">
130-
{% if login.isCrawler.value == 'yes' %}
131-
<span class="badge text-bg-primary">Yes</span>
132-
{% else %}
133-
<span class="badge text-bg-secondary">No</span>
134-
{% endif %}
135-
</td>
141+
<td class="column-login-deviceBrand">{{ login.deviceBrand }}</td>
142+
<td class="column-login-deviceModel">{{ login.deviceModel }}</td>
143+
<td class="column-login-osPlatform">{{ login.osPlatform }}</td>
144+
<td class="column-login-clientEngine">{{ login.clientEngine }}</td>
145+
<td class="column-login-clientVersion">{{ login.clientVersion }}</td>
136146
<td class="column-login-created">{{ login.getCreated()|date('Y-m-d H:i:s') }}</td>
137147
</tr>
138148
{% endfor %}

src/Core/src/Admin/src/Entity/Admin.php

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ class Admin extends AbstractEntity implements UserEntityInterface
3232
use TimestampsTrait;
3333
use UuidIdentifierTrait;
3434

35-
/** @var non-empty-string|null $identity */
35+
/** @var non-empty-string $identity */
3636
#[ORM\Column(name: 'identity', type: 'string', length: 191, unique: true)]
37-
protected ?string $identity = null;
37+
protected string $identity;
3838

3939
#[ORM\Column(name: 'firstName', type: 'string', length: 191, nullable: true)]
4040
protected ?string $firstName = null;
@@ -43,7 +43,7 @@ class Admin extends AbstractEntity implements UserEntityInterface
4343
protected ?string $lastName = null;
4444

4545
#[ORM\Column(name: 'password', type: 'string', length: 191)]
46-
protected ?string $password = null;
46+
protected string $password;
4747

4848
#[ORM\Column(
4949
type: 'admin_status_enum',
@@ -71,16 +71,11 @@ public function __construct()
7171
$this->settings = new ArrayCollection();
7272
}
7373

74-
public function getIdentity(): ?string
74+
public function getIdentity(): string
7575
{
7676
return $this->identity;
7777
}
7878

79-
public function hasIdentity(): bool
80-
{
81-
return $this->identity !== null;
82-
}
83-
8479
/**
8580
* @param non-empty-string $identity
8681
*/
@@ -91,6 +86,11 @@ public function setIdentity(string $identity): self
9186
return $this;
9287
}
9388

89+
public function hasIdentity(): bool
90+
{
91+
return ! empty($this->identity);
92+
}
93+
9494
public function getFirstName(): ?string
9595
{
9696
return $this->firstName;
@@ -115,7 +115,7 @@ public function setLastName(string $lastName): self
115115
return $this;
116116
}
117117

118-
public function getPassword(): ?string
118+
public function getPassword(): string
119119
{
120120
return $this->password;
121121
}
@@ -213,9 +213,12 @@ public function isActive(): bool
213213
return $this->status === AdminStatusEnum::Active;
214214
}
215215

216+
/**
217+
* @return non-empty-string
218+
*/
216219
public function getIdentifier(): string
217220
{
218-
return (string) $this->identity;
221+
return $this->identity;
219222
}
220223

221224
/**

src/Core/src/Admin/src/Entity/AdminLogin.php

Lines changed: 92 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,12 @@ class AdminLogin extends AbstractEntity
3939
#[ORM\Column(name: 'deviceType', type: 'string', length: 191, nullable: true)]
4040
protected ?string $deviceType = null;
4141

42+
#[ORM\Column(name: 'deviceBrand', type: 'string', length: 191, nullable: true)]
43+
protected ?string $deviceBrand = null;
44+
45+
#[ORM\Column(name: 'deviceModel', type: 'string', length: 40, nullable: true)]
46+
protected ?string $deviceModel = null;
47+
4248
#[ORM\Column(type: 'yes_no_enum', nullable: true, enumType: YesNoEnum::class)]
4349
protected YesNoEnum $isMobile = YesNoEnum::No;
4450

@@ -48,14 +54,20 @@ class AdminLogin extends AbstractEntity
4854
#[ORM\Column(name: 'osVersion', type: 'string', length: 191, nullable: true)]
4955
protected ?string $osVersion = null;
5056

57+
#[ORM\Column(name: 'osPlatform', type: 'string', length: 191, nullable: true)]
58+
protected ?string $osPlatform = null;
59+
5160
#[ORM\Column(name: 'clientType', type: 'string', length: 191, nullable: true)]
5261
protected ?string $clientType = null;
5362

5463
#[ORM\Column(name: 'clientName', type: 'string', length: 191, nullable: true)]
5564
protected ?string $clientName = null;
5665

57-
#[ORM\Column(type: 'yes_no_enum', nullable: true, enumType: YesNoEnum::class)]
58-
protected YesNoEnum $isCrawler = YesNoEnum::No;
66+
#[ORM\Column(name: 'clientEngine', type: 'string', length: 191, nullable: true)]
67+
protected ?string $clientEngine = null;
68+
69+
#[ORM\Column(name: 'clientVersion', type: 'string', length: 191, nullable: true)]
70+
protected ?string $clientVersion = null;
5971

6072
#[ORM\Column(type: 'success_failure_enum', nullable: true, enumType: SuccessFailureEnum::class)]
6173
protected SuccessFailureEnum $loginStatus = SuccessFailureEnum::Fail;
@@ -132,6 +144,30 @@ public function setDeviceType(?string $deviceType): self
132144
return $this;
133145
}
134146

147+
public function getDeviceBrand(): ?string
148+
{
149+
return $this->deviceBrand;
150+
}
151+
152+
public function setDeviceBrand(?string $deviceBrand): self
153+
{
154+
$this->deviceBrand = $deviceBrand;
155+
156+
return $this;
157+
}
158+
159+
public function getDeviceModel(): ?string
160+
{
161+
return $this->deviceModel;
162+
}
163+
164+
public function setDeviceModel(?string $deviceModel): self
165+
{
166+
$this->deviceModel = $deviceModel;
167+
168+
return $this;
169+
}
170+
135171
public function getIsMobile(): ?YesNoEnum
136172
{
137173
return $this->isMobile;
@@ -168,6 +204,18 @@ public function setOsVersion(?string $osVersion): self
168204
return $this;
169205
}
170206

207+
public function getOsPlatform(): ?string
208+
{
209+
return $this->osPlatform;
210+
}
211+
212+
public function setOsPlatform(?string $osPlatform): self
213+
{
214+
$this->osPlatform = $osPlatform;
215+
216+
return $this;
217+
}
218+
171219
public function getClientType(): ?string
172220
{
173221
return $this->clientType;
@@ -192,14 +240,26 @@ public function setClientName(?string $clientName): self
192240
return $this;
193241
}
194242

195-
public function getIsCrawler(): ?YesNoEnum
243+
public function getClientEngine(): ?string
244+
{
245+
return $this->clientEngine;
246+
}
247+
248+
public function setClientEngine(?string $clientEngine): self
249+
{
250+
$this->clientEngine = $clientEngine;
251+
252+
return $this;
253+
}
254+
255+
public function getClientVersion(): ?string
196256
{
197-
return $this->isCrawler;
257+
return $this->clientVersion;
198258
}
199259

200-
public function setIsCrawler(YesNoEnum $isCrawler): self
260+
public function setClientVersion(?string $clientVersion): self
201261
{
202-
$this->isCrawler = $isCrawler;
262+
$this->clientVersion = $clientVersion;
203263

204264
return $this;
205265
}
@@ -225,12 +285,16 @@ public function setLoginStatus(SuccessFailureEnum $loginStatus): self
225285
* continent: string|null,
226286
* organization: string|null,
227287
* deviceType: string|null,
228-
* isMobile: 'no'|'yes',
288+
* deviceBrand: string|null,
289+
* deviceModel: string|null,
290+
* isMobile: string,
229291
* osName: string|null,
230292
* osVersion: string|null,
293+
* osPlatform: string|null,
231294
* clientType: string|null,
232295
* clientName: string|null,
233-
* isCrawler: 'no'|'yes',
296+
* clientEngine: string|null,
297+
* clientVersion: string|null,
234298
* loginStatus: string,
235299
* created: DateTimeImmutable|null,
236300
* updated: DateTimeImmutable|null,
@@ -239,22 +303,26 @@ public function setLoginStatus(SuccessFailureEnum $loginStatus): self
239303
public function getArrayCopy(): array
240304
{
241305
return [
242-
'id' => $this->id->toString(),
243-
'identity' => $this->identity,
244-
'adminIp' => $this->adminIp,
245-
'country' => $this->country,
246-
'continent' => $this->continent,
247-
'organization' => $this->organization,
248-
'deviceType' => $this->deviceType,
249-
'isMobile' => $this->isMobile->value,
250-
'osName' => $this->osName,
251-
'osVersion' => $this->osVersion,
252-
'clientType' => $this->clientType,
253-
'clientName' => $this->clientName,
254-
'isCrawler' => $this->isCrawler->value,
255-
'loginStatus' => $this->loginStatus->value,
256-
'created' => $this->created,
257-
'updated' => $this->updated,
306+
'id' => $this->id->toString(),
307+
'identity' => $this->identity,
308+
'adminIp' => $this->adminIp,
309+
'country' => $this->country,
310+
'continent' => $this->continent,
311+
'organization' => $this->organization,
312+
'deviceType' => $this->deviceType,
313+
'deviceBrand' => $this->deviceBrand,
314+
'deviceModel' => $this->deviceModel,
315+
'isMobile' => $this->isMobile->value,
316+
'osName' => $this->osName,
317+
'osVersion' => $this->osVersion,
318+
'osPlatform' => $this->osPlatform,
319+
'clientType' => $this->clientType,
320+
'clientName' => $this->clientName,
321+
'clientEngine' => $this->clientEngine,
322+
'clientVersion' => $this->clientVersion,
323+
'loginStatus' => $this->loginStatus->value,
324+
'created' => $this->created,
325+
'updated' => $this->updated,
258326
];
259327
}
260328
}

src/Core/src/App/src/Entity/NumericIdentifierTrait.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ trait NumericIdentifierTrait
1111
#[ORM\Id]
1212
#[ORM\Column(name: 'id', type: 'integer', options: ['unsigned' => true])]
1313
#[ORM\GeneratedValue(strategy: 'AUTO')]
14-
protected ?int $id;
14+
protected int $id;
1515

16-
public function getId(): ?int
16+
public function getId(): int
1717
{
1818
return $this->id;
1919
}

0 commit comments

Comments
 (0)