Skip to content

Commit

Permalink
TASK: Make SecondFactor creationDate nullable
Browse files Browse the repository at this point in the history
  • Loading branch information
JamesAlias committed Sep 26, 2024
1 parent b28ff70 commit 0b2458c
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
14 changes: 9 additions & 5 deletions Classes/Domain/Model/SecondFactor.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Sandstorm\NeosTwoFactorAuthentication\Domain\Model;

use DateTime;
use Neos\Flow\Http\InvalidArgumentException;
use Neos\Flow\Security\Account;
use Doctrine\ORM\Mapping as ORM;
Expand Down Expand Up @@ -39,10 +40,13 @@ class SecondFactor
protected string $secret;

/**
* @var \DateTime
* @ORM\Column(type="datetime", nullable=false)
* Introduced with version 1.4.0
* Nullable for backwards compatibility. Null values will be shown as '-' in backend module.
*
* @var DateTime|null
* @ORM\Column(type="datetime", nullable=true)
*/
protected \DateTime $creationDate;
protected DateTime|null $creationDate;

/**
* @return Account
Expand Down Expand Up @@ -100,12 +104,12 @@ public function setSecret(string $secret): void
$this->secret = $secret;
}

public function getCreationDate(): \DateTime
public function getCreationDate(): DateTime|null
{
return $this->creationDate;
}

public function setCreationDate(\DateTime $creationDate): void
public function setCreationDate(DateTime $creationDate): void
{
$this->creationDate = $creationDate;
}
Expand Down
2 changes: 1 addition & 1 deletion Migrations/Mysql/Version20240812091514.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public function up(Schema $schema): void
"Migration can only be executed safely on '\Doctrine\DBAL\Platforms\MySqlPlatform,'."
);

$this->addSql('ALTER TABLE sandstorm_neostwofactorauthentication_domain_model_secondfactor ADD creationdate DATETIME NOT NULL');
$this->addSql('ALTER TABLE sandstorm_neostwofactorauthentication_domain_model_secondfactor ADD creationdate DATETIME DEFAULT NULL');
}

public function down(Schema $schema): void
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ prototype(Sandstorm.NeosTwoFactorAuthentication:Component.SecondFactorList.Entry
<tr>
<td>{props.factorAndPerson.user.name.fullName} ({props.factorAndPerson.secondFactor.account.accountIdentifier})</td>
<td>{props.factorAndPerson.secondFactor.typeAsName}</td>
<td>{Date.format(props.factorAndPerson.secondFactor.creationDate, 'U') < 0 ? '-' : Date.format(props.factorAndPerson.secondFactor.creationDate, 'Y-m-d H:i')}</td>
<td>{props.factorAndPerson.secondFactor.creationDate == null ? '-' : Date.format(props.factorAndPerson.secondFactor.creationDate, 'Y-m-d H:i')}</td>
<td>
<button class="neos-button neos-button-danger" data-toggle="modal"
href={'#user-' + props.iterator.index} title={I18n.id('module.index.list.action.delete').package('Sandstorm.NeosTwoFactorAuthentication').source('Backend').translate()} data-neos-toggle="tooltip">
Expand Down

0 comments on commit 0b2458c

Please sign in to comment.