Skip to content

Commit 0080877

Browse files
committed
feat: Add reset password
1 parent 113cac2 commit 0080877

36 files changed

+798
-49
lines changed

.env

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,5 @@ MAILER_DSN=null://null
4141
# MESSENGER_TRANSPORT_DSN=doctrine://default?auto_setup=0
4242
MESSENGER_TRANSPORT_DSN=redis://redis:6379/messages
4343
###< symfony/messenger ###
44+
45+
APP_URL=https://acme.localhost

Makefile

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,20 @@ help:
99
## Docker
1010
##
1111

12-
# Build the containers
13-
install:
12+
# Init database !!! Caution: will flush all data !!!
13+
init_database:
14+
@docker compose exec php bin/console doctrine:schema:drop --force --full-database
15+
@docker compose exec php bin/console doctrine:migrations:migrate -n
16+
@docker compose exec php bin/console doctrine:fixtures:load -n
17+
18+
# Init SSL certificates
19+
init_ssl:
1420
@mkcert "acme.localhost"
1521
@mv "acme.localhost.pem" docker/ssl/certificate.pem
1622
@mv "acme.localhost-key.pem" docker/ssl/certificate-key.pem
17-
@docker compose build
23+
24+
# Build the containers
25+
install: init_ssl start init_database stop
1826

1927
set_permissions:
2028
@docker compose exec php chown -R www-data:www-data /srv/var

composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
"symfony/uid": "7.2.*",
3737
"symfony/validator": "7.2.*",
3838
"symfony/yaml": "7.2.*",
39+
"symfonycasts/reset-password-bundle": "^1.23",
3940
"twig/extra-bundle": "^2.12|^3.18",
4041
"twig/intl-extra": "^3.18",
4142
"twig/twig": "^2.12|^3.18.0"

composer.lock

Lines changed: 49 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/bundles.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,5 @@
1616
Scheb\TwoFactorBundle\SchebTwoFactorBundle::class => ['all' => true],
1717
Doctrine\Bundle\FixturesBundle\DoctrineFixturesBundle::class => ['dev' => true, 'test' => true],
1818
BabDev\PagerfantaBundle\BabDevPagerfantaBundle::class => ['all' => true],
19+
SymfonyCasts\Bundle\ResetPassword\SymfonyCastsResetPasswordBundle::class => ['all' => true],
1920
];

config/packages/reset_password.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
use App\Repository\ResetPasswordRequestRepository;
6+
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
7+
8+
return static function (ContainerConfigurator $container): void {
9+
$container->extension('symfonycasts_reset_password', [
10+
'request_password_repository' => ResetPasswordRequestRepository::class,
11+
]);
12+
};

config/packages/routing.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
6+
use Symfony\Config\Framework\RouterConfig;
7+
use Symfony\Config\FrameworkConfig;
8+
9+
return static function (ContainerConfigurator $containerConfigurator, FrameworkConfig $framework): void {
10+
$router = $framework->router();
11+
assert($router instanceof RouterConfig);
12+
13+
$router->defaultUri('%env(APP_URL)%');
14+
if ('prod' === $containerConfigurator->env()) {
15+
$router->strictRequirements(null);
16+
}
17+
};

config/packages/routing.yaml

Lines changed: 0 additions & 10 deletions
This file was deleted.

config/packages/security.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ security:
4343
access_control:
4444
- { path: ^/login, roles: PUBLIC_ACCESS }
4545
- { path: ^/logout, role: PUBLIC_ACCESS }
46+
- { path: ^/reset-password, role: PUBLIC_ACCESS }
4647
- { path: ^/2fa, role: IS_AUTHENTICATED_2FA_IN_PROGRESS }
4748
- { path: ^/admin, roles: ROLE_ADMIN }
4849
- { path: ^/, roles: ROLE_USER }

migrations/Version00000000000000.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,26 @@ public function up(Schema $schema): void
3838
PRIMARY KEY(id) )
3939
DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci`
4040
ENGINE = InnoDB
41+
SQL,
42+
);
43+
44+
$this->addSql(
45+
<<<'SQL'
46+
CREATE TABLE reset_password_request ( id INT AUTO_INCREMENT NOT NULL,
47+
user_id INT UNSIGNED NOT NULL,
48+
selector VARCHAR(20) NOT NULL,
49+
hashed_token VARCHAR(100) NOT NULL,
50+
requested_at DATETIME NOT NULL COMMENT "(DC2Type:datetime_immutable)",
51+
expires_at DATETIME NOT NULL COMMENT "(DC2Type:datetime_immutable)",
52+
INDEX IDX_7CE748AA76ED395 (user_id),
53+
PRIMARY KEY(id) )
54+
DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci`
55+
ENGINE = InnoDB
56+
SQL,
57+
);
58+
$this->addSql(
59+
<<<'SQL'
60+
ALTER TABLE reset_password_request ADD CONSTRAINT FK_7CE748AA76ED395 FOREIGN KEY (user_id) REFERENCES `user` (id)
4161
SQL,
4262
);
4363
}

0 commit comments

Comments
 (0)