mirror of
https://gitlab.linphone.org/BC/public/flexisip-account-manager.git
synced 2026-01-17 10:08:05 +00:00
Fix FLEXIAPI-403 Fix #14183 Cast the DotEnv setting to integer before passing them to Carbon
This commit is contained in:
parent
ed28e8fe55
commit
57e09cc4de
2 changed files with 5 additions and 5 deletions
|
|
@ -40,7 +40,7 @@ abstract class Consommable extends Model
|
||||||
public function getExpireAtAttribute(): ?string
|
public function getExpireAtAttribute(): ?string
|
||||||
{
|
{
|
||||||
if ($this->isExpirable()) {
|
if ($this->isExpirable()) {
|
||||||
return $this->created_at->addMinutes(config('app.' . $this->configExpirationMinutesKey))->toJSON();
|
return $this->created_at->addMinutes((int)config('app.' . $this->configExpirationMinutesKey))->toJSON();
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
|
@ -49,13 +49,13 @@ abstract class Consommable extends Model
|
||||||
public function expired(): bool
|
public function expired(): bool
|
||||||
{
|
{
|
||||||
return ($this->isExpirable()
|
return ($this->isExpirable()
|
||||||
&& Carbon::now()->subMinutes(config('app.' . $this->configExpirationMinutesKey))->isAfter($this->created_at));
|
&& Carbon::now()->subMinutes((int)config('app.' . $this->configExpirationMinutesKey))->isAfter($this->created_at));
|
||||||
}
|
}
|
||||||
|
|
||||||
private function isExpirable(): bool
|
private function isExpirable(): bool
|
||||||
{
|
{
|
||||||
return $this->configExpirationMinutesKey != null
|
return $this->configExpirationMinutesKey != null
|
||||||
&& config('app.' . $this->configExpirationMinutesKey) != null
|
&& config('app.' . $this->configExpirationMinutesKey) != null
|
||||||
&& config('app.' . $this->configExpirationMinutesKey) > 0;
|
&& (int)config('app.' . $this->configExpirationMinutesKey) > 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -370,7 +370,7 @@ class AccountProvisioningTest extends TestCase
|
||||||
{
|
{
|
||||||
$account = Account::factory()->create();
|
$account = Account::factory()->create();
|
||||||
$account->generateUserApiKey();
|
$account->generateUserApiKey();
|
||||||
$expirationMinutes = 10;
|
$expirationMinutes = '10'; // Set is as a string to mimic DotEnv parsing
|
||||||
|
|
||||||
$this->keyAuthenticated($account)
|
$this->keyAuthenticated($account)
|
||||||
->get('/api/accounts/me/provision')
|
->get('/api/accounts/me/provision')
|
||||||
|
|
@ -385,7 +385,7 @@ class AccountProvisioningTest extends TestCase
|
||||||
->get('/api/accounts/me/provision')
|
->get('/api/accounts/me/provision')
|
||||||
->assertStatus(200)
|
->assertStatus(200)
|
||||||
->assertJson([
|
->assertJson([
|
||||||
'provisioning_token_expire_at' => $account->currentProvisioningToken->created_at->addMinutes($expirationMinutes)->toJSON()
|
'provisioning_token_expire_at' => $account->currentProvisioningToken->created_at->addMinutes((int)$expirationMinutes)->toJSON()
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$account->refresh();
|
$account->refresh();
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue