Skip to content

Commit

Permalink
Making the verification and password reset token unqiue
Browse files Browse the repository at this point in the history
  • Loading branch information
mamazu committed Nov 3, 2023
1 parent 9518e82 commit 052a759
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 2 deletions.
37 changes: 37 additions & 0 deletions src/Sylius/Bundle/CoreBundle/Migrations/Version20231103004216.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php

declare(strict_types=1);

namespace Sylius\Bundle\CoreBundle\Migrations;

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

/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20231103004216 extends AbstractMigration
{
public function getDescription(): string
{
return 'Making the uniqueness of the password_reset_token and email_verification_token a database constraint';
}

public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('CREATE UNIQUE INDEX UNIQ_88D5CC4D6B7BA4B6 ON sylius_admin_user (password_reset_token)');
$this->addSql('CREATE UNIQUE INDEX UNIQ_88D5CC4DC4995C67 ON sylius_admin_user (email_verification_token)');
$this->addSql('CREATE UNIQUE INDEX UNIQ_7C2B74806B7BA4B6 ON sylius_shop_user (password_reset_token)');
$this->addSql('CREATE UNIQUE INDEX UNIQ_7C2B7480C4995C67 ON sylius_shop_user (email_verification_token)');
}

public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('DROP INDEX UNIQ_88D5CC4D6B7BA4B6 ON sylius_admin_user');
$this->addSql('DROP INDEX UNIQ_88D5CC4DC4995C67 ON sylius_admin_user');
$this->addSql('DROP INDEX UNIQ_7C2B74806B7BA4B6 ON sylius_shop_user');
$this->addSql('DROP INDEX UNIQ_7C2B7480C4995C67 ON sylius_shop_user');
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@
<field name="encoderName" column="encoder_name" type="string" nullable="true" />

<field name="lastLogin" column="last_login" type="datetime" nullable="true" />
<field name="passwordResetToken" column="password_reset_token" type="string" nullable="true" />
<field name="passwordResetToken" column="password_reset_token" type="string" nullable="true" unique="true" />
<field name="passwordRequestedAt" column="password_requested_at" type="datetime" nullable="true" />
<field name="emailVerificationToken" column="email_verification_token" type="string" nullable="true" />
<field name="emailVerificationToken" column="email_verification_token" type="string" nullable="true" unique="true" />
<field name="verifiedAt" column="verified_at" type="datetime" nullable="true" />

<field name="locked" column="locked" type="boolean" nullable="false" />
Expand Down

0 comments on commit 052a759

Please sign in to comment.