Skip to content

Commit 61a9eae

Browse files
jrushlowweaverryan
authored andcommitted
temp. disable make forgotten password
1 parent ccb68bf commit 61a9eae

File tree

8 files changed

+35
-17
lines changed

8 files changed

+35
-17
lines changed

src/Maker/MakeForgottenPassword.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,23 +15,23 @@
1515
use Symfony\Bundle\MakerBundle\DependencyBuilder;
1616
use Symfony\Bundle\MakerBundle\Doctrine\ORMDependencyBuilder;
1717
use Symfony\Bundle\MakerBundle\Exception\RuntimeCommandException;
18+
use Symfony\Bundle\MakerBundle\FileManager;
1819
use Symfony\Bundle\MakerBundle\Generator;
1920
use Symfony\Bundle\MakerBundle\InputConfiguration;
21+
use Symfony\Bundle\MakerBundle\Renderer\FormTypeRenderer;
2022
use Symfony\Bundle\MakerBundle\Security\InteractiveSecurityHelper;
2123
use Symfony\Bundle\MakerBundle\Util\YamlSourceManipulator;
2224
use Symfony\Bundle\SecurityBundle\SecurityBundle;
25+
use Symfony\Bundle\SwiftmailerBundle\SwiftmailerBundle;
2326
use Symfony\Bundle\TwigBundle\TwigBundle;
2427
use Symfony\Component\Console\Command\Command;
2528
use Symfony\Component\Console\Input\InputInterface;
2629
use Symfony\Component\Form\AbstractType;
27-
use Symfony\Component\Form\Extension\Core\Type\PasswordType;
2830
use Symfony\Component\Form\Extension\Core\Type\EmailType;
31+
use Symfony\Component\Form\Extension\Core\Type\PasswordType;
2932
use Symfony\Component\Form\Extension\Core\Type\RepeatedType;
3033
use Symfony\Component\Routing\RouterInterface;
31-
use Symfony\Bundle\MakerBundle\FileManager;
32-
use Symfony\Bundle\MakerBundle\Renderer\FormTypeRenderer;
3334
use Symfony\Component\Validator\Validation;
34-
use Symfony\Bundle\SwiftmailerBundle\SwiftmailerBundle;
3535

3636
/**
3737
* @author Romaric Drigon <[email protected]>

src/Renderer/FormTypeRenderer.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,17 @@ public function render(ClassNameDetails $formClassDetails, array $formFields, Cl
4242
$fields[$name] = $fieldTypeOptions;
4343
}
4444

45+
$mergedTypeUseStatements = array_merge($fieldTypeUseStatements, $extraUseClasses);
46+
sort($mergedTypeUseStatements);
47+
4548
$this->generator->generateClass(
4649
$formClassDetails->getFullName(),
4750
'form/Type.tpl.php',
4851
[
4952
'bounded_full_class_name' => $boundClassDetails ? $boundClassDetails->getFullName() : null,
5053
'bounded_class_name' => $boundClassDetails ? $boundClassDetails->getShortName() : null,
5154
'form_fields' => $fields,
52-
'field_type_use_statements' => array_merge($fieldTypeUseStatements, $extraUseClasses),
55+
'field_type_use_statements' => $mergedTypeUseStatements,
5356
'constraint_use_statements' => $constraintClasses,
5457
]
5558
);

src/Resources/config/makers.xml

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,14 @@
4242
<tag name="maker.command" />
4343
</service>
4444

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

5254
<service id="maker.maker.make_form" class="Symfony\Bundle\MakerBundle\Maker\MakeForm">
5355
<argument type="service" id="maker.doctrine_helper" />

src/Resources/skeleton/forgottenPassword/ForgottenPasswordController.tpl.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -106,15 +106,15 @@ public function reset(Request $request, UserPasswordEncoderInterface $passwordEn
106106
throw $this->createNotFoundException();
107107
}
108108

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

113113
if (!$passwordResetToken) {
114114
throw $this->createNotFoundException();
115115
}
116116

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

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

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

131131
// Encode the plain password, and set it.

src/Security/SecurityControllerBuilder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public function addLogoutMethod(ClassSourceManipulator $manipulator)
7171
$manipulator->addUseStatementIfNecessary(Route::class);
7272
$manipulator->addMethodBody($logoutMethodBuilder, <<<'CODE'
7373
<?php
74-
throw new \Exception('This method can be blank - it will be intercepted by the logout key on your firewall');
74+
throw new \LogicException('This method can be blank - it will be intercepted by the logout key on your firewall.');
7575
CODE
7676
);
7777
$manipulator->addMethodBuilder($logoutMethodBuilder);

tests/Maker/FunctionalTest.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use Symfony\Bundle\FrameworkBundle\Console\Application;
1616
use Symfony\Bundle\MakerBundle\Command\MakerCommand;
1717
use Symfony\Bundle\MakerBundle\Maker\AbstractMaker;
18+
use Symfony\Bundle\MakerBundle\Maker\MakeForgottenPassword;
1819
use Symfony\Bundle\MakerBundle\Test\MakerTestKernel;
1920
use Symfony\Component\Finder\Finder;
2021

@@ -39,6 +40,11 @@ public function testWiring()
3940
continue;
4041
}
4142

43+
/** Skip make forgotten password as it is temp. disabled (tkt#537) */
44+
if (MakeForgottenPassword::class === $class) {
45+
continue;
46+
}
47+
4248
$commandName = $class::getCommandName();
4349
// if the command does not exist, this will explode
4450
$command = $application->find($commandName);

tests/Maker/MakeForgottenPasswordTest.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,14 @@
88

99
class MakeForgottenPasswordTest extends MakerTestCase
1010
{
11+
/**
12+
* Test skipped until make forgotten password is enabled again.
13+
* @see https://github.com/symfony/maker-bundle/issues/537
14+
*/
1115
public function getTestDetails()
1216
{
17+
$this->markTestSkipped('Temp. Disabled make forgotten password. See ');
18+
1319
yield 'forgotten_password' => [MakerTestDetails::createTest(
1420
$this->getMakerInstance(MakeForgottenPassword::class),
1521
[
@@ -21,6 +27,7 @@ public function getTestDetails()
2127
->setFixtureFilesPath(__DIR__.'/../fixtures/MakeForgottenPassword')
2228
->configureDatabase()
2329
->updateSchemaAfterCommand()
30+
->addExtraDependencies('symfony/swiftmailer-bundle')
2431
];
2532
}
2633
}

tests/Security/fixtures/expected/SecurityController_login_logout.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,6 @@ public function login(AuthenticationUtils $authenticationUtils): Response
3131
*/
3232
public function logout()
3333
{
34-
throw new \Exception('This method can be blank - it will be intercepted by the logout key on your firewall');
34+
throw new \LogicException('This method can be blank - it will be intercepted by the logout key on your firewall.');
3535
}
3636
}

0 commit comments

Comments
 (0)