Skip to content

Commit

Permalink
Merge pull request #454 from nucleos/1.12.x-merge-up-into-2.0.x_zPdDsXy6
Browse files Browse the repository at this point in the history
Merge release 1.12.0 into 2.0.x
  • Loading branch information
nucleos-bot committed Oct 10, 2021
2 parents 02d8df4 + 6eb0c1d commit f468bf1
Show file tree
Hide file tree
Showing 17 changed files with 185 additions and 115 deletions.
47 changes: 34 additions & 13 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,50 @@

All notable changes to this project will be documented in this file, in reverse chronological order by release.

## 1.12.0 - TBD
## 1.12.0 - 2021-10-09

### Added

- Nothing.

### Changed
-----

### Release Notes for [1.12.0](https://github.com/nucleos/NucleosUserBundle/milestone/10)

Feature release (minor)

### 1.12.0

- Total issues resolved: **0**
- Total pull requests resolved: **3**
- Total contributors: **2**

#### Enhancement

- [453: Allow overriding loggedin route](https://github.com/nucleos/NucleosUserBundle/pull/453) thanks to @core23
- [421: Adapt phpstan config for the new getArgument() return type](https://github.com/nucleos/NucleosUserBundle/pull/421) thanks to @lgeorget

- Nothing.
#### dependency

### Deprecated
- [445: Remove egulias/email-validator dependency](https://github.com/nucleos/NucleosUserBundle/pull/445) thanks to @core23

- Nothing.
## 1.11.2 - 2021-09-15

### Removed

- Nothing.
-----

### Release Notes for [1.11.2](https://github.com/nucleos/NucleosUserBundle/milestone/11)

1.11.x bugfix release (patch)

### Fixed
### 1.11.2

- Total issues resolved: **0**
- Total pull requests resolved: **1**
- Total contributors: **1**

#### Bug

- [433: Fix html for resetting mail](https://github.com/nucleos/NucleosUserBundle/pull/433) thanks to @core23

- Nothing.

## 1.11.1 - 2021-08-04

Expand All @@ -44,8 +67,6 @@ All notable changes to this project will be documented in this file, in reverse
#### Bug

- [397: PatternValidator ignores null values and does not throw an exception anymore](https://github.com/nucleos/NucleosUserBundle/pull/397) thanks to @AubreyHewes
=======


## 1.11.0 - 2021-07-02

Expand Down
1 change: 0 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
"doctrine/common": "^2.11 || ^3.0",
"doctrine/event-manager": "^1.1",
"doctrine/persistence": "^1.3 || ^2.1",
"egulias/email-validator": "^2.1.10",
"paragonie/random_compat": "^1 || ^2 || ^9",
"symfony/config": "^5.3",
"symfony/console": "^5.3",
Expand Down
2 changes: 2 additions & 0 deletions docs/configuration_reference.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,5 @@ All available configuration options are listed below with their default values.
group:
group_class: ~ # Required when using groups
group_manager: nucleos_user.group_manager.default
loggedin:
route: 'nucleos_user_security_loggedin' # Required with 2.0 release
2 changes: 2 additions & 0 deletions docs/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,8 @@ of datastore you are using.
firewall_name: main
user_class: App\Entity\User
from_email: "%mailer_user%"
loggedin:
route: 'nucleos_user_security_loggedin' # Redirect route after login
Only four configuration's nodes are required to use the bundle:
Expand Down
7 changes: 6 additions & 1 deletion phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ parameters:

-
message: "#^Call to an undefined method Symfony\\\\Component\\\\Config\\\\Definition\\\\Builder\\\\NodeDefinition\\:\\:addDefaultsIfNotSet\\(\\)\\.$#"
count: 2
count: 3
path: src/DependencyInjection/Configuration.php

-
Expand All @@ -65,6 +65,11 @@ parameters:
count: 1
path: src/DependencyInjection/NucleosUserExtension.php

-
message: "#^Method Nucleos\\\\UserBundle\\\\DependencyInjection\\\\NucleosUserExtension\\:\\:loadLoggedin\\(\\) has parameter \\$config with no value type specified in iterable type array\\.$#"
count: 1
path: src/DependencyInjection/NucleosUserExtension.php

-
message: "#^Method Nucleos\\\\UserBundle\\\\DependencyInjection\\\\NucleosUserExtension\\:\\:loadResetting\\(\\) has parameter \\$config with no value type specified in iterable type array\\.$#"
count: 1
Expand Down
4 changes: 3 additions & 1 deletion psalm-baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@
</NullableReturnStatement>
</file>
<file src="src/DependencyInjection/Configuration.php">
<UndefinedMethod occurrences="5">
<UndefinedMethod occurrences="6">
<code>addDefaultsIfNotSet</code>
<code>addDefaultsIfNotSet</code>
<code>addDefaultsIfNotSet</code>
<code>addDefaultsIfNotSet</code>
<code>children</code>
Expand Down
11 changes: 9 additions & 2 deletions src/Action/ChangePasswordAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,19 @@ final class ChangePasswordAction

private UserManagerInterface $userManager;

/**
* @var string
*/
private $loggedinRoute;

public function __construct(
Environment $twig,
RouterInterface $router,
Security $security,
EventDispatcherInterface $eventDispatcher,
FormFactoryInterface $formFactory,
UserManagerInterface $userManager
UserManagerInterface $userManager,
string $loggedinRoute
) {
$this->twig = $twig;
$this->router = $router;
Expand All @@ -61,6 +67,7 @@ public function __construct(

$this->eventDispatcher = $eventDispatcher;
$this->formFactory = $formFactory;
$this->loggedinRoute = $loggedinRoute;
}

/**
Expand Down Expand Up @@ -101,7 +108,7 @@ public function __invoke(Request $request): Response
$this->userManager->updateUser($user);

if (null === $response = $event->getResponse()) {
$url = $this->router->generate('nucleos_user_security_loggedin');
$url = $this->router->generate($this->loggedinRoute);
$response = new RedirectResponse($url);
}

Expand Down
3 changes: 3 additions & 0 deletions src/Action/LoggedinAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
use Symfony\Contracts\EventDispatcher\EventDispatcherInterface;
use Twig\Environment;

/**
* @deprecated since 1.12.0.
*/
final class LoggedinAction
{
private Environment $twig;
Expand Down
9 changes: 6 additions & 3 deletions src/Action/ResetAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,18 +39,22 @@ final class ResetAction

private UserManagerInterface $userManager;

private string $loggedinRoute;

public function __construct(
Environment $twig,
RouterInterface $router,
EventDispatcherInterface $eventDispatcher,
FormFactoryInterface $formFactory,
UserManagerInterface $userManager
UserManagerInterface $userManager,
string $loggedinRoute
) {
$this->twig = $twig;
$this->router = $router;
$this->eventDispatcher = $eventDispatcher;
$this->formFactory = $formFactory;
$this->userManager = $userManager;
$this->loggedinRoute = $loggedinRoute;
}

public function __invoke(Request $request, string $token): Response
Expand Down Expand Up @@ -88,8 +92,7 @@ public function __invoke(Request $request, string $token): Response
$this->userManager->updateUser($user);

if (null === $response = $event->getResponse()) {
$url = $this->router->generate('nucleos_user_security_loggedin');
$response = new RedirectResponse($url);
$response = new RedirectResponse($this->router->generate($this->loggedinRoute));
}

$this->eventDispatcher->dispatch(
Expand Down
16 changes: 16 additions & 0 deletions src/DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public function getConfigTreeBuilder(): TreeBuilder
$this->addDeletionSection($rootNode);
$this->addGroupSection($rootNode);
$this->addServiceSection($rootNode);
$this->addLoggedinSection($rootNode);

return $treeBuilder;
}
Expand Down Expand Up @@ -136,4 +137,19 @@ private function addGroupSection(NodeDefinition $node): void
->end()
;
}

private function addLoggedinSection(NodeDefinition $node): void
{
$node
->addDefaultsIfNotSet()
->children()
->arrayNode('loggedin')
->addDefaultsIfNotSet()
->children()
->scalarNode('route')->defaultValue('nucleos_user_security_loggedin')->cannotBeEmpty()->end()
->end()
->end()
->end()
;
}
}
6 changes: 6 additions & 0 deletions src/DependencyInjection/NucleosUserExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ public function load(array $configs, ContainerBuilder $container): void
$this->loadChangePassword($loader);
$this->loadDeletion($config['deletion'], $loader);
$this->loadResetting($config['resetting'], $container, $loader, $config['from_email']);
$this->loadLoggedin($config['loggedin'], $container);

if (isset($config['group'])) {
$this->loadGroups($config['group'], $container, $loader, $config['db_driver']);
Expand Down Expand Up @@ -241,4 +242,9 @@ private function loadGroups(array $config, ContainerBuilder $container, FileLoad
],
]);
}

private function loadLoggedin(array $config, ContainerBuilder $container): void
{
$container->setParameter('nucleos_user.loggedin.route', $config['route']);
}
}
1 change: 1 addition & 0 deletions src/Resources/config/change_password.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
new Reference('event_dispatcher'),
new Reference('form.factory'),
new Reference('nucleos_user.user_manager'),
'%nucleos_user.loggedin.route%',
])

;
Expand Down
1 change: 1 addition & 0 deletions src/Resources/config/resetting.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
new Reference('event_dispatcher'),
new Reference('form.factory'),
new Reference('nucleos_user.user_manager'),
'%nucleos_user.loggedin.route%',
])

->set(SendEmailAction::class)
Expand Down
2 changes: 1 addition & 1 deletion src/Resources/views/Resetting/email.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
{{ 'resetting.email.html'|trans({
'%username%': user.username,
'%confirmationUrl%': confirmationUrl
}) }}
})|raw }}
3 changes: 3 additions & 0 deletions tests/DependencyInjection/ConfigurationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ public function testOptions(): void
'username_canonicalizer' => 'nucleos_user.util.canonicalizer.default',
'user_manager' => 'nucleos_user.user_manager.default',
],
'loggedin' => [
'route' => 'nucleos_user_security_loggedin',
],
];

static::assertSame($expected, $config);
Expand Down
1 change: 1 addition & 0 deletions tests/DependencyInjection/NucleosUserExtensionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ public function testUserLoadUtilServiceWithDefaults(): void
{
$this->createEmptyConfiguration();

$this->assertParameter('nucleos_user_security_loggedin', 'nucleos_user.loggedin.route');
$this->assertAlias('nucleos_user.mailer.default', 'nucleos_user.mailer');
$this->assertAlias('nucleos_user.util.canonicalizer.default', 'nucleos_user.util.email_canonicalizer');
$this->assertAlias('nucleos_user.util.canonicalizer.default', 'nucleos_user.util.username_canonicalizer');
Expand Down
Loading

0 comments on commit f468bf1

Please sign in to comment.