Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: SymfonyCasts/reset-password-bundle
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v1.22.0
Choose a base ref
...
head repository: SymfonyCasts/reset-password-bundle
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: main
Choose a head ref
  • 15 commits
  • 35 files changed
  • 8 contributors

Commits on Jun 6, 2024

  1. Copy the full SHA
    b64c0bb View commit details
  2. [ci] fix wrong tmp path in php-cs-fixer config (#323)

    finder `exclude` paths must be relative to the `in` paths. This
    prevents php-cs-fixer from attempting to scan/fix files in
    `tests/tmp/cache/etc...`
    jrushlow authored Jun 6, 2024
    Copy the full SHA
    8d67b00 View commit details

Commits on Jun 11, 2024

  1. minor #325 [dx] keep tooling in one place

    * [dx] keep tooling in one place
    
    * we dont need phpstan here anymore
    jrushlow authored Jun 11, 2024
    Copy the full SHA
    f121481 View commit details

Commits on Jun 13, 2024

  1. feature #326 [translations] port DA, FA, & ID from VerifyEmailBundle

    - Only includes time related strings e.g. `hour`, `minute`, etc...
    jrushlow authored Jun 13, 2024
    Copy the full SHA
    f883f86 View commit details

Commits on Jun 14, 2024

  1. Copy the full SHA
    1b61be3 View commit details

Commits on Jul 4, 2024

  1. Copy the full SHA
    564db7c View commit details

Commits on Jul 30, 2024

  1. Copy the full SHA
    ef7dba7 View commit details

Commits on Aug 29, 2024

  1. Copy the full SHA
    13b3466 View commit details

Commits on Aug 31, 2024

  1. Copy the full SHA
    85e59bb View commit details

Commits on Oct 8, 2024

  1. Add CI status badge (#336)

    This should help with noticing failed CI builds
    bocharsky-bw authored Oct 8, 2024
    Copy the full SHA
    7f3423e View commit details

Commits on Oct 22, 2024

  1. Added .neon files to ignore export. (#338)

    * Added .neon files to ignore export.
    
    * Added tools directory to export ignore.
    
    * Better reordering of the gitattributes list
    
    ---------
    
    Co-authored-by: Victor Bocharsky <bocharsky.bw@gmail.com>
    laurentmuller and bocharsky-bw authored Oct 22, 2024
    Copy the full SHA
    59d02ee View commit details

Commits on Nov 8, 2024

  1. Copy the full SHA
    d96b3be View commit details
  2. Merge pull request #340 from Speelwolf/main

    Replacing Static Fake Token with Randomized 32-Character Token
    kbond authored Nov 8, 2024
    Copy the full SHA
    419a328 View commit details

Commits on Dec 9, 2024

  1. Copy the full SHA
    bde42fe View commit details

Commits on Feb 7, 2025

  1. Copy the full SHA
    79d3394 View commit details
Showing with 793 additions and 14 deletions.
  1. +3 −1 .gitattributes
  2. +3 −0 .php-cs-fixer.dist.php
  3. +2 −0 README.md
  4. +21 −3 composer.json
  5. +2 −0 phpunit.xml.dist
  6. +1 −1 src/Command/ResetPasswordRemoveExpiredCommand.php
  7. +1 −1 src/Model/ResetPasswordToken.php
  8. +5 −3 src/ResetPasswordHelper.php
  9. +27 −0 src/Resources/translations/ResetPasswordBundle.da.xlf
  10. +27 −0 src/Resources/translations/ResetPasswordBundle.fa.xlf
  11. +27 −0 src/Resources/translations/ResetPasswordBundle.id.xlf
  12. +24 −0 src/Resources/translations/ResetPasswordBundle.it.xlf
  13. +24 −0 src/Resources/translations/ResetPasswordBundle.pt.xlf
  14. +5 −0 tests/Fixtures/App/.env
  15. +2 −0 tests/Fixtures/App/config/packages/reset_password.yaml
  16. +12 −0 tests/Fixtures/App/config/routes.yaml
  17. +185 −0 tests/Fixtures/App/src/Controller/ResetPasswordController.php
  18. +46 −0 tests/Fixtures/App/src/Entity/ResetPasswordRequest.php
  19. +65 −0 tests/Fixtures/App/src/Form/ChangePasswordFormType.php
  20. +38 −0 tests/Fixtures/App/src/Form/ResetPasswordRequestFormType.php
  21. +39 −0 tests/Fixtures/App/src/Repository/ResetPasswordRequestRepository.php
  22. +11 −0 tests/Fixtures/App/templates/reset_password/check_email.html.twig
  23. +9 −0 tests/Fixtures/App/templates/reset_password/email.html.twig
  24. +22 −0 tests/Fixtures/App/templates/reset_password/request.html.twig
  25. +12 −0 tests/Fixtures/App/templates/reset_password/reset.html.twig
  26. +111 −0 tests/Fixtures/App/tests/ResetPasswordControllerTest.php
  27. +1 −1 tests/Fixtures/ResetPasswordTestFixtureRequestRepository.php
  28. +51 −0 tests/FunctionalTests/ResetPasswordFunctionalTest.php
  29. +1 −1 tests/UnitTests/Model/ResetPasswordRequestTraitTest.php
  30. +1 −1 tests/UnitTests/Model/ResetPasswordTokenTest.php
  31. +2 −2 tests/UnitTests/Persistence/ResetPasswordRequestRepositoryTraitTest.php
  32. +1 −0 tests/tmp/.gitignore
  33. +2 −0 tools/.gitignore
  34. +5 −0 tools/php-cs-fixer/composer.json
  35. +5 −0 tools/phpstan/composer.json
4 changes: 3 additions & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
/docs export-ignore
/.github export-ignore
/docs export-ignore
/tests export-ignore
/tools export-ignore
.gitattributes export-ignore
.gitignore export-ignore
.neon export-ignore
.php_cs.dist export-ignore
phpunit.xml.dist export-ignore
psalm.xml export-ignore
3 changes: 3 additions & 0 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
@@ -6,6 +6,9 @@

$finder = (new PhpCsFixer\Finder())
->in([__DIR__.'/src', __DIR__.'/tests'])
->exclude([
'tmp'
])
;

return (new PhpCsFixer\Config())
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# ResetPasswordBundle: Mind-Blowing (and Secure) Password Resetting for Symfony

[![CI](https://github.com/SymfonyCasts/reset-password-bundle/actions/workflows/ci.yaml/badge.svg)](https://github.com/SymfonyCasts/reset-password-bundle/actions/workflows/ci.yaml)

Worrying about how to deal with users that can't remember their password? We've
got you covered! This bundle provides a secure out of the box solution to allow
users to reset their forgotten passwords.
24 changes: 21 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
@@ -6,7 +6,6 @@
"minimum-stability": "dev",
"require": {
"php": ">=8.1.10",
"ext-json": "*",
"symfony/config": "^5.4 | ^6.0 | ^7.0",
"symfony/dependency-injection": "^5.4 | ^6.0 | ^7.0",
"symfony/deprecation-contracts": "^2.2 | ^3.0",
@@ -18,7 +17,8 @@
"symfony/phpunit-bridge": "^5.4 | ^6.0 | ^7.0",
"doctrine/doctrine-bundle": "^2.8",
"doctrine/annotations": "^1.0",
"phpstan/phpstan": "^1.11.x-dev"
"symfony/process": "^6.4 | ^7.0 | ^7.1",
"symfonycasts/internal-test-helpers": "dev-main"
},
"autoload": {
"psr-4": {
@@ -30,7 +30,25 @@
"SymfonyCasts\\Bundle\\ResetPassword\\Tests\\": "tests/"
}
},
"repositories": [
{
"type": "vcs",
"name": "symfonycasts/internal-test-helpers",
"url": "https://github.com/symfonycasts/internal-test-helpers"
}
],
"scripts": {
"phpstan": "vendor/bin/phpstan"
"tools:upgrade": [
"@tools:upgrade:php-cs-fixer",
"@tools:upgrade:phpstan"
],
"tools:upgrade:php-cs-fixer": "composer upgrade -W -d tools/php-cs-fixer",
"tools:upgrade:phpstan": "composer upgrade -W -d tools/phpstan",
"tools:run": [
"@tools:run:php-cs-fixer",
"@tools:run:phpstan"
],
"tools:run:php-cs-fixer": "tools/php-cs-fixer/vendor/bin/php-cs-fixer fix",
"tools:run:phpstan": "tools/phpstan/vendor/bin/phpstan --memory-limit=1G"
}
}
2 changes: 2 additions & 0 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -29,6 +29,8 @@
<testsuites>
<testsuite name="all">
<directory>./tests</directory>
<exclude>tests/tmp</exclude>
<exclude>tests/Fixtures</exclude>
</testsuite>
<testsuite name="unit">
<directory>./tests/UnitTests</directory>
2 changes: 1 addition & 1 deletion src/Command/ResetPasswordRemoveExpiredCommand.php
Original file line number Diff line number Diff line change
@@ -42,7 +42,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int

$intRemoved = $this->cleaner->handleGarbageCollection(true);

$output->writeln(sprintf('Garbage collection successful. Removed %s reset password request object(s).', $intRemoved));
$output->writeln(\sprintf('Garbage collection successful. Removed %s reset password request object(s).', $intRemoved));

return 0;
}
2 changes: 1 addition & 1 deletion src/Model/ResetPasswordToken.php
Original file line number Diff line number Diff line change
@@ -135,7 +135,7 @@ public function getExpirationMessageData(): array
public function getExpiresAtIntervalInstance(): \DateInterval
{
if (null === $this->generatedAt) {
throw new \LogicException(sprintf('%s initialized without setting the $generatedAt timestamp.', self::class));
throw new \LogicException(\sprintf('%s initialized without setting the $generatedAt timestamp.', self::class));
}

$createdAtTime = \DateTimeImmutable::createFromFormat('U', (string) $this->generatedAt);
8 changes: 5 additions & 3 deletions src/ResetPasswordHelper.php
Original file line number Diff line number Diff line change
@@ -72,7 +72,7 @@ public function generateResetToken(object $user, ?int $resetRequestLifetime = nu

$resetRequestLifetime = $resetRequestLifetime ?? $this->resetRequestLifetime;

$expiresAt = new \DateTimeImmutable(sprintf('+%d seconds', $resetRequestLifetime));
$expiresAt = new \DateTimeImmutable(\sprintf('+%d seconds', $resetRequestLifetime));

$generatedAt = ($expiresAt->getTimestamp() - $resetRequestLifetime);

@@ -164,11 +164,13 @@ public function getTokenLifetime(): int
public function generateFakeResetToken(?int $resetRequestLifetime = null): ResetPasswordToken
{
$resetRequestLifetime = $resetRequestLifetime ?? $this->resetRequestLifetime;
$expiresAt = new \DateTimeImmutable(sprintf('+%d seconds', $resetRequestLifetime));
$expiresAt = new \DateTimeImmutable(\sprintf('+%d seconds', $resetRequestLifetime));

$generatedAt = ($expiresAt->getTimestamp() - $resetRequestLifetime);

return new ResetPasswordToken('fake-token', $expiresAt, $generatedAt);
$fakeToken = bin2hex(random_bytes(16));

return new ResetPasswordToken($fakeToken, $expiresAt, $generatedAt);
}

private function findResetPasswordRequest(string $token): ?ResetPasswordRequestInterface
27 changes: 27 additions & 0 deletions src/Resources/translations/ResetPasswordBundle.da.xlf
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="UTF-8" ?>
<xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" version="1.2">
<file original="file.ext" source-language="en" target-language="da" datatype="plaintext">
<body>
<trans-unit id="1">
<source>%count% year|%count% years</source>
<target>%count% år|%count% år</target>
</trans-unit>
<trans-unit id="2">
<source>%count% month|%count% months</source>
<target>%count% måned|%count% måneder</target>
</trans-unit>
<trans-unit id="3">
<source>%count% day|%count% days</source>
<target>%count% dag|%count% dage</target>
</trans-unit>
<trans-unit id="4">
<source>%count% hour|%count% hours</source>
<target>%count% time|%count% timer</target>
</trans-unit>
<trans-unit id="5">
<source>%count% minute|%count% minutes</source>
<target>%count% minut|%count% minutter</target>
</trans-unit>
</body>
</file>
</xliff>
27 changes: 27 additions & 0 deletions src/Resources/translations/ResetPasswordBundle.fa.xlf
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="UTF-8" ?>
<xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" version="1.2">
<file original="file.ext" source-language="en" target-language="fa" datatype="plaintext">
<body>
<trans-unit id="1">
<source>%count% year|%count% years</source>
<target>%count% سال|%count% سال‌</target>
</trans-unit>
<trans-unit id="2">
<source>%count% month|%count% months</source>
<target>%count% ماه|%count% ماه‌</target>
</trans-unit>
<trans-unit id="3">
<source>%count% day|%count% days</source>
<target>%count% روز|%count% روز</target>
</trans-unit>
<trans-unit id="4">
<source>%count% hour|%count% hours</source>
<target>%count% ساعت|%count% ساعت</target>
</trans-unit>
<trans-unit id="5">
<source>%count% minute|%count% minutes</source>
<target>%count% دقیقه|%count% دقیقه</target>
</trans-unit>
</body>
</file>
</xliff>
27 changes: 27 additions & 0 deletions src/Resources/translations/ResetPasswordBundle.id.xlf
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="UTF-8" ?>
<xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" version="1.2">
<file original="file.ext" source-language="en" target-language="id" datatype="plaintext">
<body>
<trans-unit id="1">
<source>%count% year|%count% years</source>
<target>%count% tahun|%count% tahun</target>
</trans-unit>
<trans-unit id="2">
<source>%count% month|%count% months</source>
<target>%count% bulan|%count% bulan</target>
</trans-unit>
<trans-unit id="3">
<source>%count% day|%count% days</source>
<target>%count% hari|%count% hari</target>
</trans-unit>
<trans-unit id="4">
<source>%count% hour|%count% hours</source>
<target>%count% jam|%count% jam</target>
</trans-unit>
<trans-unit id="5">
<source>%count% minute|%count% minutes</source>
<target>%count% menit|%count% menit</target>
</trans-unit>
</body>
</file>
</xliff>
24 changes: 24 additions & 0 deletions src/Resources/translations/ResetPasswordBundle.it.xlf
Original file line number Diff line number Diff line change
@@ -22,6 +22,30 @@
<source>%count% minute|%count% minutes</source>
<target>%count% minuto|%count% minuti</target>
</trans-unit>
<trans-unit id="6">
<source>There was a problem validating your password reset request</source>
<target>Si è verificato un problema durante la convalida della richiesta di reimpostazione della password</target>
</trans-unit>
<trans-unit id="7">
<source>There was a problem handling your password reset request</source>
<target>Si è verificato un problema durante l'elaborazione della richiesta di reimpostazione della password</target>
</trans-unit>
<trans-unit id="8">
<source>The link in your email is expired. Please try to reset your password again.</source>
<target>Il link nella tua e-mail è scaduto. Provi a reimpostare nuovamente la password.</target>
</trans-unit>
<trans-unit id="9">
<source>Please update the request_password_repository configuration in config/packages/reset_password.yaml to point to your "request password repository" service.</source>
<target>Aggiornare la configurazione request_password_repository in config/packages/reset_password.yaml per puntare al servizio "request password repository".</target>
</trans-unit>
<trans-unit id="10">
<source>The reset password link is invalid. Please try to reset your password again.</source>
<target>Il link per la reimpostazione della password non è valido. Riprovare a reimpostare la password</target>
</trans-unit>
<trans-unit id="11">
<source>You have already requested a reset password email. Please check your email or try again soon.</source>
<target>Hai già richiesto un'e-mail di reimpostazione della password. Si prega di controllare la posta elettronica o di riprovare al più presto.</target>
</trans-unit>
</body>
</file>
</xliff>
24 changes: 24 additions & 0 deletions src/Resources/translations/ResetPasswordBundle.pt.xlf
Original file line number Diff line number Diff line change
@@ -22,6 +22,30 @@
<source>%count% minute|%count% minutes</source>
<target>%count% minuto|%count% minutos</target>
</trans-unit>
<trans-unit id="6">
<source>There was a problem validating your password reset request</source>
<target>Houve um problema ao validar sua solicitação de redefinição de senha</target>
</trans-unit>
<trans-unit id="7">
<source>There was a problem handling your password reset request</source>
<target>Houve um problema ao processar sua solicitação de redefinição de senha</target>
</trans-unit>
<trans-unit id="8">
<source>The link in your email is expired. Please try to reset your password again.</source>
<target>O link no seu e-mail expirou. Por favor, tente redefinir sua senha novamente.</target>
</trans-unit>
<trans-unit id="9">
<source>Please update the request_password_repository configuration in config/packages/reset_password.yaml to point to your "request password repository" service.</source>
<target>Por favor, atualize a configuração de request_password_repository em config/packages/reset_password.yaml para apontar para o seu serviço de "request password repository".</target>
</trans-unit>
<trans-unit id="10">
<source>The reset password link is invalid. Please try to reset your password again.</source>
<target>O link para redefinição de senha é inválido. Por favor, tente redefinir sua senha novamente.</target>
</trans-unit>
<trans-unit id="11">
<source>You have already requested a reset password email. Please check your email or try again soon.</source>
<target>Você já solicitou um e-mail para redefinição de senha. Verifique seu e-mail ou tente novamente em breve.</target>
</trans-unit>
</body>
</file>
</xliff>
5 changes: 5 additions & 0 deletions tests/Fixtures/App/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
APP_ENV=dev
APP_SECRET=7e6cd3398232b047dc249e51729039fa
DATABASE_URL="sqlite:///%kernel.project_dir%/var/data.db"
MESSENGER_TRANSPORT_DSN=doctrine://default?auto_setup=0
MAILER_DSN=null://null
2 changes: 2 additions & 0 deletions tests/Fixtures/App/config/packages/reset_password.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
symfonycasts_reset_password:
request_password_repository: App\Repository\ResetPasswordRequestRepository
12 changes: 12 additions & 0 deletions tests/Fixtures/App/config/routes.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
controllers:
resource:
path: ../src/Controller/
namespace: App\Controller
type: attribute

app_home:
path: /
controller: Symfony\Bundle\FrameworkBundle\Controller\TemplateController
defaults:
template: 'base.html.twig'
statusCode: 200
Loading