Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion bin/composer-post-install-script.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,12 @@ function getEnvironment(): string
],
[
'source' => 'vendor/dotkernel/dot-mail/config/mail.global.php.dist',
'destination' => 'config/autoload/mail.global.php',
'destination' => 'config/autoload/mail.local.php',
'environment' => [ENVIRONMENT_DEVELOPMENT, ENVIRONMENT_PRODUCTION],
],
[
'source' => 'vendor/dotkernel/dot-mail/config/mail.global.php.dist',
'destination' => 'config/autoload/mail.local.php.dist',
'environment' => [ENVIRONMENT_DEVELOPMENT, ENVIRONMENT_PRODUCTION],
],
];
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
"laminas/laminas-component-installer": "^3.7.0",
"laminas/laminas-config-aggregator": "^1.19.0",
"mezzio/mezzio": "^3.26.0",
"mezzio/mezzio-authentication-oauth2": "^2.13.0",
"mezzio/mezzio-authentication-oauth2": "^3.0.1",
"mezzio/mezzio-authorization-rbac": "^1.10.0",
"mezzio/mezzio-cors": "^1.15.0",
"mezzio/mezzio-fastroute": "^3.14.0",
Expand Down
15 changes: 12 additions & 3 deletions src/Admin/src/Service/AdminLoginService.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,11 @@ public function getAdminLogins(array $params): array
'login.osVersion',
'login.clientType',
'login.clientName',
'login.isCrawler',
'login.deviceBrand',
'login.deviceModel',
'login.osPlatform',
'login.clientEngine',
'login.clientVersion',
'login.loginStatus',
'login.identity',
'login.created',
Expand Down Expand Up @@ -111,7 +115,8 @@ private function logAdminVisit(array $serverParams, string $name, SuccessFailure
*/
$browser = new stdClass();
if (ini_get('browscap')) {
$browser = get_browser($_SERVER['HTTP_USER_AGENT']);
$result = get_browser($_SERVER['HTTP_USER_AGENT']);
$browser = $result instanceof stdClass ? $result : $browser;
}

$adminLogin = (new AdminLogin())
Expand All @@ -128,7 +133,11 @@ private function logAdminVisit(array $serverParams, string $name, SuccessFailure
->setClientType(! empty($browser->browser_type) ? $browser->browser_type : null)
->setClientName(! empty($browser->browser) ? $browser->browser : null)
->setLoginStatus($status)
->setIsCrawler(! empty($browser->crawler) ? YesNoEnum::Yes : YesNoEnum::No)
->setDeviceBrand(! empty($browser->device_brand) ? $browser->device_brand : null)
->setDeviceBrand(! empty($browser->device_model) ? $browser->device_model : null)
->setDeviceBrand(! empty($browser->platform_version) ? $browser->platform_version : null)
->setDeviceBrand(! empty($browser->browser_engine) ? $browser->browser_engine : null)
->setDeviceBrand(! empty($browser->browser_version) ? $browser->browser_version : null)
->setIdentity($name);

$this->adminLoginRepository->saveResource($adminLogin);
Expand Down
28 changes: 19 additions & 9 deletions src/Admin/templates/admin/list-admin-login.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,20 @@
<th class="column-login-clientName">
{{ sortableColumn('admin::list-admin-login', {}, pagination.queryParams, 'login.clientName', 'Client Name') }}
</th>
<th class="column-login-isCrawler">
{{ sortableColumn('admin::list-admin-login', {}, pagination.queryParams, 'login.isCrawler', 'Is Crawler') }}
<th class="column-login-deviceBrand">
{{ sortableColumn('admin::list-admin-login', {}, pagination.queryParams, 'login.deviceBrand', 'Device Brand') }}
</th>
<th class="column-login-deviceModel">
{{ sortableColumn('admin::list-admin-login', {}, pagination.queryParams, 'login.deviceModel', 'Device Model') }}
</th>
<th class="column-login-osPlatform">
{{ sortableColumn('admin::list-admin-login', {}, pagination.queryParams, 'login.osPlatform', 'Os Platform') }}
</th>
<th class="column-login-clientEngine">
{{ sortableColumn('admin::list-admin-login', {}, pagination.queryParams, 'login.clientEngine', 'Client Engine') }}
</th>
<th class="column-login-clientVersion">
{{ sortableColumn('admin::list-admin-login', {}, pagination.queryParams, 'login.clientVersion', 'Client Version') }}
</th>
<th class="column-login-created">
{{ sortableColumn('admin::list-admin-login', {}, pagination.queryParams, 'login.created', 'Created') }}
Expand Down Expand Up @@ -126,13 +138,11 @@
<td class="column-login-osVersion">{{ login.osVersion }}</td>
<td class="column-login-clientType">{{ login.clientType }}</td>
<td class="column-login-clientName">{{ login.clientName }}</td>
<td class="column-login-isCrawler">
{% if login.isCrawler.value == 'yes' %}
<span class="badge text-bg-primary">Yes</span>
{% else %}
<span class="badge text-bg-secondary">No</span>
{% endif %}
</td>
<td class="column-login-deviceBrand">{{ login.deviceBrand }}</td>
<td class="column-login-deviceModel">{{ login.deviceModel }}</td>
<td class="column-login-osPlatform">{{ login.osPlatform }}</td>
<td class="column-login-clientEngine">{{ login.clientEngine }}</td>
<td class="column-login-clientVersion">{{ login.clientVersion }}</td>
<td class="column-login-created">{{ login.getCreated()|date('Y-m-d H:i:s') }}</td>
</tr>
{% endfor %}
Expand Down
25 changes: 14 additions & 11 deletions src/Core/src/Admin/src/Entity/Admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ class Admin extends AbstractEntity implements UserEntityInterface
use TimestampsTrait;
use UuidIdentifierTrait;

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

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

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

#[ORM\Column(
type: 'admin_status_enum',
Expand Down Expand Up @@ -71,16 +71,11 @@ public function __construct()
$this->settings = new ArrayCollection();
}

public function getIdentity(): ?string
public function getIdentity(): string
{
return $this->identity;
}

public function hasIdentity(): bool
{
return $this->identity !== null;
}

/**
* @param non-empty-string $identity
*/
Expand All @@ -91,6 +86,11 @@ public function setIdentity(string $identity): self
return $this;
}

public function hasIdentity(): bool
{
return ! empty($this->identity);
}

public function getFirstName(): ?string
{
return $this->firstName;
Expand All @@ -115,7 +115,7 @@ public function setLastName(string $lastName): self
return $this;
}

public function getPassword(): ?string
public function getPassword(): string
{
return $this->password;
}
Expand Down Expand Up @@ -213,9 +213,12 @@ public function isActive(): bool
return $this->status === AdminStatusEnum::Active;
}

/**
* @return non-empty-string
*/
public function getIdentifier(): string
{
return (string) $this->identity;
return $this->identity;
}

/**
Expand Down
116 changes: 92 additions & 24 deletions src/Core/src/Admin/src/Entity/AdminLogin.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@ class AdminLogin extends AbstractEntity
#[ORM\Column(name: 'deviceType', type: 'string', length: 191, nullable: true)]
protected ?string $deviceType = null;

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

#[ORM\Column(name: 'deviceModel', type: 'string', length: 40, nullable: true)]
protected ?string $deviceModel = null;

#[ORM\Column(type: 'yes_no_enum', nullable: true, enumType: YesNoEnum::class)]
protected YesNoEnum $isMobile = YesNoEnum::No;

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

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

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

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

#[ORM\Column(type: 'yes_no_enum', nullable: true, enumType: YesNoEnum::class)]
protected YesNoEnum $isCrawler = YesNoEnum::No;
#[ORM\Column(name: 'clientEngine', type: 'string', length: 191, nullable: true)]
protected ?string $clientEngine = null;

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

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

public function getDeviceBrand(): ?string
{
return $this->deviceBrand;
}

public function setDeviceBrand(?string $deviceBrand): self
{
$this->deviceBrand = $deviceBrand;

return $this;
}

public function getDeviceModel(): ?string
{
return $this->deviceModel;
}

public function setDeviceModel(?string $deviceModel): self
{
$this->deviceModel = $deviceModel;

return $this;
}

public function getIsMobile(): ?YesNoEnum
{
return $this->isMobile;
Expand Down Expand Up @@ -168,6 +204,18 @@ public function setOsVersion(?string $osVersion): self
return $this;
}

public function getOsPlatform(): ?string
{
return $this->osPlatform;
}

public function setOsPlatform(?string $osPlatform): self
{
$this->osPlatform = $osPlatform;

return $this;
}

public function getClientType(): ?string
{
return $this->clientType;
Expand All @@ -192,14 +240,26 @@ public function setClientName(?string $clientName): self
return $this;
}

public function getIsCrawler(): ?YesNoEnum
public function getClientEngine(): ?string
{
return $this->clientEngine;
}

public function setClientEngine(?string $clientEngine): self
{
$this->clientEngine = $clientEngine;

return $this;
}

public function getClientVersion(): ?string
{
return $this->isCrawler;
return $this->clientVersion;
}

public function setIsCrawler(YesNoEnum $isCrawler): self
public function setClientVersion(?string $clientVersion): self
{
$this->isCrawler = $isCrawler;
$this->clientVersion = $clientVersion;

return $this;
}
Expand All @@ -225,12 +285,16 @@ public function setLoginStatus(SuccessFailureEnum $loginStatus): self
* continent: string|null,
* organization: string|null,
* deviceType: string|null,
* isMobile: 'no'|'yes',
* deviceBrand: string|null,
* deviceModel: string|null,
* isMobile: string,
* osName: string|null,
* osVersion: string|null,
* osPlatform: string|null,
* clientType: string|null,
* clientName: string|null,
* isCrawler: 'no'|'yes',
* clientEngine: string|null,
* clientVersion: string|null,
* loginStatus: string,
* created: DateTimeImmutable|null,
* updated: DateTimeImmutable|null,
Expand All @@ -239,22 +303,26 @@ public function setLoginStatus(SuccessFailureEnum $loginStatus): self
public function getArrayCopy(): array
{
return [
'id' => $this->id->toString(),
'identity' => $this->identity,
'adminIp' => $this->adminIp,
'country' => $this->country,
'continent' => $this->continent,
'organization' => $this->organization,
'deviceType' => $this->deviceType,
'isMobile' => $this->isMobile->value,
'osName' => $this->osName,
'osVersion' => $this->osVersion,
'clientType' => $this->clientType,
'clientName' => $this->clientName,
'isCrawler' => $this->isCrawler->value,
'loginStatus' => $this->loginStatus->value,
'created' => $this->created,
'updated' => $this->updated,
'id' => $this->id->toString(),
'identity' => $this->identity,
'adminIp' => $this->adminIp,
'country' => $this->country,
'continent' => $this->continent,
'organization' => $this->organization,
'deviceType' => $this->deviceType,
'deviceBrand' => $this->deviceBrand,
'deviceModel' => $this->deviceModel,
'isMobile' => $this->isMobile->value,
'osName' => $this->osName,
'osVersion' => $this->osVersion,
'osPlatform' => $this->osPlatform,
'clientType' => $this->clientType,
'clientName' => $this->clientName,
'clientEngine' => $this->clientEngine,
'clientVersion' => $this->clientVersion,
'loginStatus' => $this->loginStatus->value,
'created' => $this->created,
'updated' => $this->updated,
];
}
}
4 changes: 2 additions & 2 deletions src/Core/src/App/src/Entity/NumericIdentifierTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ trait NumericIdentifierTrait
#[ORM\Id]
#[ORM\Column(name: 'id', type: 'integer', options: ['unsigned' => true])]
#[ORM\GeneratedValue(strategy: 'AUTO')]
protected ?int $id;
protected int $id;

public function getId(): ?int
public function getId(): int
{
return $this->id;
}
Expand Down
4 changes: 2 additions & 2 deletions src/Core/src/App/src/Service/IpService.php
Comment thread
alexmerlin marked this conversation as resolved.
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public static function getUserIp(array $server): mixed
// check if HTTP_X_FORWARDED_FOR is public network IP
if (isset($server['HTTP_X_FORWARDED_FOR']) && self::isPublicIp($server['HTTP_X_FORWARDED_FOR'])) {
$realIp = $server['HTTP_X_FORWARDED_FOR'];
// check if HTTP_CLIENT_IP is public network IP
// check if HTTP_CLIENT_IP is public network IP
Comment thread
alexmerlin marked this conversation as resolved.
Outdated
} elseif (isset($server['HTTP_CLIENT_IP']) && self::isPublicIp($server['HTTP_CLIENT_IP'])) {
$realIp = $server['HTTP_CLIENT_IP'];
} else {
Expand All @@ -38,7 +38,7 @@ public static function getUserIp(array $server): mixed
// check if HTTP_X_FORWARDED_FOR is public network IP
if (getenv('HTTP_X_FORWARDED_FOR') && self::isPublicIp((string) getenv('HTTP_X_FORWARDED_FOR'))) {
$realIp = getenv('HTTP_X_FORWARDED_FOR');
// check if HTTP_CLIENT_IP is public network IP
// check if HTTP_CLIENT_IP is public network IP
Comment thread
alexmerlin marked this conversation as resolved.
Outdated
} elseif (getenv('HTTP_CLIENT_IP') && self::isPublicIp((string) getenv('HTTP_CLIENT_IP'))) {
$realIp = getenv('HTTP_CLIENT_IP');
} else {
Expand Down
Loading
Loading