Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/Maker/MakeForgottenPassword.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,23 @@
use Symfony\Bundle\MakerBundle\DependencyBuilder;
use Symfony\Bundle\MakerBundle\Doctrine\ORMDependencyBuilder;
use Symfony\Bundle\MakerBundle\Exception\RuntimeCommandException;
use Symfony\Bundle\MakerBundle\FileManager;
use Symfony\Bundle\MakerBundle\Generator;
use Symfony\Bundle\MakerBundle\InputConfiguration;
use Symfony\Bundle\MakerBundle\Renderer\FormTypeRenderer;
use Symfony\Bundle\MakerBundle\Security\InteractiveSecurityHelper;
use Symfony\Bundle\MakerBundle\Util\YamlSourceManipulator;
use Symfony\Bundle\SecurityBundle\SecurityBundle;
use Symfony\Bundle\SwiftmailerBundle\SwiftmailerBundle;
use Symfony\Bundle\TwigBundle\TwigBundle;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\PasswordType;
use Symfony\Component\Form\Extension\Core\Type\EmailType;
use Symfony\Component\Form\Extension\Core\Type\PasswordType;
use Symfony\Component\Form\Extension\Core\Type\RepeatedType;
use Symfony\Component\Routing\RouterInterface;
use Symfony\Bundle\MakerBundle\FileManager;
use Symfony\Bundle\MakerBundle\Renderer\FormTypeRenderer;
use Symfony\Component\Validator\Validation;
use Symfony\Bundle\SwiftmailerBundle\SwiftmailerBundle;

/**
* @author Romaric Drigon <romaric.drigon@gmail.com>
Expand Down
5 changes: 4 additions & 1 deletion src/Renderer/FormTypeRenderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,17 @@ public function render(ClassNameDetails $formClassDetails, array $formFields, Cl
$fields[$name] = $fieldTypeOptions;
}

$mergedTypeUseStatements = array_merge($fieldTypeUseStatements, $extraUseClasses);
sort($mergedTypeUseStatements);

$this->generator->generateClass(
$formClassDetails->getFullName(),
'form/Type.tpl.php',
[
'bounded_full_class_name' => $boundClassDetails ? $boundClassDetails->getFullName() : null,
'bounded_class_name' => $boundClassDetails ? $boundClassDetails->getShortName() : null,
'form_fields' => $fields,
'field_type_use_statements' => array_merge($fieldTypeUseStatements, $extraUseClasses),
'field_type_use_statements' => $mergedTypeUseStatements,
'constraint_use_statements' => $constraintClasses,
]
);
Expand Down
14 changes: 8 additions & 6 deletions src/Resources/config/makers.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,14 @@
<tag name="maker.command" />
</service>

<service id="maker.maker.make_forgotten_password" class="Symfony\Bundle\MakerBundle\Maker\MakeForgottenPassword">
<argument type="service" id="maker.file_manager" />
<argument type="service" id="maker.renderer.form_type_renderer" />
<argument type="service" id="router" />
<tag name="maker.command" />
</service>
<!-- Temporary disable make forgotten password pending refactor. Allow's for other MakerBundle releases. -->
<!-- See https://github.com/symfony/maker-bundle/issues/537 -->
<!-- <service id="maker.maker.make_forgotten_password" class="Symfony\Bundle\MakerBundle\Maker\MakeForgottenPassword">-->
<!-- <argument type="service" id="maker.file_manager" />-->
<!-- <argument type="service" id="maker.renderer.form_type_renderer" />-->
<!-- <argument type="service" id="router" />-->
<!-- <tag name="maker.command" />-->
<!-- </service>-->

<service id="maker.maker.make_form" class="Symfony\Bundle\MakerBundle\Maker\MakeForm">
<argument type="service" id="maker.doctrine_helper" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,15 +106,15 @@ public function reset(Request $request, UserPasswordEncoderInterface $passwordEn
throw $this->createNotFoundException();
}

$passwordResetToken = $this->getDoctrine()->getRepository(PasswordResetToken::class)->findOneBy([
'selector' => substr($tokenAndSelector, 0, PasswordResetToken::SELECTOR_LENGTH),
$passwordResetToken = $this->getDoctrine()->getRepository(<?= $token_class_name ?>::class)->findOneBy([
'selector' => substr($tokenAndSelector, 0, <?= $token_class_name ?>::SELECTOR_LENGTH),
]);

if (!$passwordResetToken) {
throw $this->createNotFoundException();
}

if ($passwordResetToken->isExpired() || !$passwordResetToken->isTokenEquals(substr($tokenAndSelector, PasswordResetToken::SELECTOR_LENGTH))) {
if ($passwordResetToken->isExpired() || !$passwordResetToken->isTokenEquals(substr($tokenAndSelector, <?= $token_class_name ?>::SELECTOR_LENGTH))) {
$this->getDoctrine()->getManager()->remove($passwordResetToken);
$this->getDoctrine()->getManager()->flush();

Expand All @@ -125,7 +125,7 @@ public function reset(Request $request, UserPasswordEncoderInterface $passwordEn
$form->handleRequest($request);

if ($form->isSubmitted() && $form->isValid()) {
// A PasswordResetToken should be used only once, remove it.
// A <?= $token_class_name ?> should be used only once, remove it.
$this->getDoctrine()->getManager()->remove($passwordResetToken);

// Encode the plain password, and set it.
Expand Down
2 changes: 1 addition & 1 deletion src/Security/SecurityControllerBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public function addLogoutMethod(ClassSourceManipulator $manipulator)
$manipulator->addUseStatementIfNecessary(Route::class);
$manipulator->addMethodBody($logoutMethodBuilder, <<<'CODE'
<?php
throw new \Exception('This method can be blank - it will be intercepted by the logout key on your firewall');
throw new \LogicException('This method can be blank - it will be intercepted by the logout key on your firewall.');
CODE
);
$manipulator->addMethodBuilder($logoutMethodBuilder);
Expand Down
6 changes: 6 additions & 0 deletions tests/Maker/FunctionalTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
use Symfony\Bundle\FrameworkBundle\Console\Application;
use Symfony\Bundle\MakerBundle\Command\MakerCommand;
use Symfony\Bundle\MakerBundle\Maker\AbstractMaker;
use Symfony\Bundle\MakerBundle\Maker\MakeForgottenPassword;
use Symfony\Bundle\MakerBundle\Test\MakerTestKernel;
use Symfony\Component\Finder\Finder;

Expand All @@ -39,6 +40,11 @@ public function testWiring()
continue;
}

/** Skip make forgotten password as it is temp. disabled (tkt#537) */
if (MakeForgottenPassword::class === $class) {
continue;
}

$commandName = $class::getCommandName();
// if the command does not exist, this will explode
$command = $application->find($commandName);
Expand Down
7 changes: 7 additions & 0 deletions tests/Maker/MakeForgottenPasswordTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,14 @@

class MakeForgottenPasswordTest extends MakerTestCase
{
/**
* Test skipped until make forgotten password is enabled again.
* @see https://github.com/symfony/maker-bundle/issues/537
*/
public function getTestDetails()
{
$this->markTestSkipped('Temp. Disabled make forgotten password. See ');

yield 'forgotten_password' => [MakerTestDetails::createTest(
$this->getMakerInstance(MakeForgottenPassword::class),
[
Expand All @@ -21,6 +27,7 @@ public function getTestDetails()
->setFixtureFilesPath(__DIR__.'/../fixtures/MakeForgottenPassword')
->configureDatabase()
->updateSchemaAfterCommand()
->addExtraDependencies('symfony/swiftmailer-bundle')
];
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,6 @@ public function login(AuthenticationUtils $authenticationUtils): Response
*/
public function logout()
{
throw new \Exception('This method can be blank - it will be intercepted by the logout key on your firewall');
throw new \LogicException('This method can be blank - it will be intercepted by the logout key on your firewall.');
}
}