Skip to content

Commit

Permalink
Merge pull request #24 from sandstorm/22-bug-unable-to-remove-user-wi…
Browse files Browse the repository at this point in the history
…th-existing-second-factor

BUGFIX: Correctly cascade deletion of second factor when deleting user
  • Loading branch information
JamesAlias authored Nov 17, 2023
2 parents 152f5c4 + e199795 commit 519bc45
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Classes/Domain/Model/SecondFactor.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ class SecondFactor
/**
* @var Account
* @ORM\ManyToOne
* If Account gets deleted also delete the second factors.
* @ORM\JoinColumn(onDelete="CASCADE")
*/
protected Account $account;

Expand Down
43 changes: 43 additions & 0 deletions Migrations/Mysql/Version20231114151915.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?php

declare(strict_types=1);

namespace Neos\Flow\Persistence\Doctrine\Migrations;

use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;

/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20231114151915 extends AbstractMigration
{
public function getDescription(): string
{
return '';
}

public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->abortIf(
!$this->connection->getDatabasePlatform() instanceof \Doctrine\DBAL\Platforms\MySqlPlatform,
"Migration can only be executed safely on '\Doctrine\DBAL\Platforms\MySqlPlatform,'."
);

$this->addSql('ALTER TABLE sandstorm_neostwofactorauthentication_domain_model_secondfactor DROP FOREIGN KEY FK_29EF8A7F7D3656A4');
$this->addSql('ALTER TABLE sandstorm_neostwofactorauthentication_domain_model_secondfactor ADD CONSTRAINT FK_29EF8A7F7D3656A4 FOREIGN KEY (account) REFERENCES neos_flow_security_account (persistence_object_identifier) ON DELETE CASCADE');
}

public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->abortIf(
!$this->connection->getDatabasePlatform() instanceof \Doctrine\DBAL\Platforms\MySqlPlatform,
"Migration can only be executed safely on '\Doctrine\DBAL\Platforms\MySqlPlatform,'."
);

$this->addSql('ALTER TABLE sandstorm_neostwofactorauthentication_domain_model_secondfactor DROP FOREIGN KEY FK_29EF8A7F7D3656A4');
$this->addSql('ALTER TABLE sandstorm_neostwofactorauthentication_domain_model_secondfactor ADD CONSTRAINT FK_29EF8A7F7D3656A4 FOREIGN KEY (account) REFERENCES neos_flow_security_account (persistence_object_identifier)');
}
}

0 comments on commit 519bc45

Please sign in to comment.