Skip to content

Commit

Permalink
Allow activation of legacy and inactive licenses
Browse files Browse the repository at this point in the history
Fixes #6089
  • Loading branch information
lukasbestle committed Dec 23, 2023
1 parent ba8e9e5 commit c456c21
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/Cms/License.php
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ public function request(string $path, array $data): array
*/
public function save(): bool
{
if ($this->status() !== LicenseStatus::Active) {
if ($this->status()->activatable() !== true) {
throw new InvalidArgumentException([
'key' => 'license.verification'
]);
Expand Down
16 changes: 16 additions & 0 deletions src/Cms/LicenseStatus.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,22 @@ enum LicenseStatus: string
*/
case Missing = 'missing';

/**
* Checks if the license can be saved when it
* was entered in the activation dialog;
* renewable licenses are accepted as well
* to allow renewal from the Panel
*/
public function activatable(): bool
{
return match ($this) {
static::Active => true,
static::Inactive => true,
static::Legacy => true,
default => false
};
}

/**
* Returns the dialog according to the status
*/
Expand Down
2 changes: 1 addition & 1 deletion tests/Cms/System/LicenseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ public function testRenewal()
/**
* @covers ::save
*/
public function testSaveWhenNotActive()
public function testSaveWhenNotActivatable()
{
$license = new License();

Expand Down

0 comments on commit c456c21

Please sign in to comment.