Skip to content

Commit 4440da7

Browse files
author
roadiz-ci
committed
refactor: Removed base RozierApp class when possible, added LogTrail service for publishing message in session and logger
1 parent 297df80 commit 4440da7

File tree

9 files changed

+100
-582
lines changed

9 files changed

+100
-582
lines changed

composer.json

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@
2525
"ext-json": "*",
2626
"ext-mbstring": "*",
2727
"api-platform/core": "~3.3.11",
28-
"doctrine/annotations": "^1.0",
28+
"doctrine/annotations": "^2.0",
2929
"doctrine/doctrine-bundle": "^2.8.1",
3030
"doctrine/doctrine-migrations-bundle": "^3.1",
31-
"doctrine/orm": "~2.19.0",
31+
"doctrine/orm": "~2.20.0",
3232
"gedmo/doctrine-extensions": "^3.16.1",
3333
"inlinestyle/inlinestyle": "~1.2.7",
3434
"james-heinrich/getid3": "^1.9",
@@ -52,18 +52,17 @@
5252
"roadiz/models": "2.4.x-dev",
5353
"roadiz/nodetype-contracts": "~1.1.2",
5454
"roadiz/random": "2.4.x-dev",
55-
"rollerworks/password-common-list": "^0.2.0",
56-
"rollerworks/password-strength-bundle": "^2.2",
55+
"rollerworks/password-common-list": "^0.3.0",
56+
"rollerworks/password-strength-bundle": "^3.0",
5757
"scienta/doctrine-json-functions": "^4.2",
58-
"sensio/framework-extra-bundle": "^6.1",
59-
"solarium/solarium": "^6.0.4",
60-
"symfony-cmf/routing-bundle": "^3.0.2",
58+
"solarium/solarium": "^6.3.6",
59+
"symfony-cmf/routing-bundle": "^3.1.0",
6160
"symfony/asset": "6.4.*",
6261
"symfony/cache": "6.4.*",
6362
"symfony/console": "6.4.*",
6463
"symfony/dotenv": "6.4.*",
6564
"symfony/expression-language": "6.4.*",
66-
"symfony/flex": "^2.2.3",
65+
"symfony/flex": "^2.4.7",
6766
"symfony/form": "6.4.*",
6867
"symfony/framework-bundle": "6.4.*",
6968
"symfony/http-client": "6.4.*",

config/services.yaml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -441,7 +441,12 @@ services:
441441
arguments: ['%kernel.project_dir%']
442442
public: true
443443

444-
RZ\Roadiz\Random\PasswordGenerator: ~
444+
RZ\Roadiz\Random\PasswordGeneratorInterface:
445+
class: RZ\Roadiz\Random\PasswordGenerator
446+
RZ\Roadiz\Random\SaltGeneratorInterface:
447+
class: RZ\Roadiz\Random\SaltGenerator
448+
RZ\Roadiz\Random\TokenGeneratorInterface:
449+
class: RZ\Roadiz\Random\TokenGenerator
445450

446451
JMS\Serializer\Construction\ObjectConstructorInterface:
447452
alias: RZ\Roadiz\CoreBundle\Serializer\ObjectConstructor\ObjectConstructor

src/Console/UsersPasswordCommand.php

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
use Doctrine\Persistence\ManagerRegistry;
88
use RZ\Roadiz\CoreBundle\Entity\User;
9-
use RZ\Roadiz\Random\PasswordGenerator;
9+
use RZ\Roadiz\Random\PasswordGeneratorInterface;
1010
use Symfony\Component\Console\Input\InputArgument;
1111
use Symfony\Component\Console\Input\InputInterface;
1212
use Symfony\Component\Console\Output\OutputInterface;
@@ -16,7 +16,7 @@
1616
final class UsersPasswordCommand extends UsersCommand
1717
{
1818
public function __construct(
19-
private readonly PasswordGenerator $passwordGenerator,
19+
private readonly PasswordGeneratorInterface $passwordGenerator,
2020
ManagerRegistry $managerRegistry,
2121
?string $name = null,
2222
) {
@@ -31,6 +31,11 @@ protected function configure(): void
3131
'username',
3232
InputArgument::REQUIRED,
3333
'Username'
34+
)->addOption(
35+
'length',
36+
'l',
37+
InputArgument::OPTIONAL,
38+
default: 16,
3439
);
3540
}
3641

@@ -49,7 +54,9 @@ protected function execute(InputInterface $input, OutputInterface $output): int
4954
$confirmation
5055
)
5156
) {
52-
$user->setPlainPassword($this->passwordGenerator->generatePassword(12));
57+
$user->setPlainPassword($this->passwordGenerator->generatePassword(
58+
(int) $input->getOption('length')
59+
));
5360
$this->managerRegistry->getManagerForClass(User::class)->flush();
5461
$io->success('A new password was regenerated for '.$name.': '.$user->getPlainPassword());
5562

src/Security/Authentication/RoadizAuthenticator.php

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,8 @@ abstract class RoadizAuthenticator extends AbstractLoginFormAuthenticator
2929
{
3030
use TargetPathTrait;
3131

32-
public const LOGIN_ROUTE = 'loginPage';
33-
3432
public function __construct(
35-
private readonly UrlGeneratorInterface $urlGenerator,
33+
protected readonly UrlGeneratorInterface $urlGenerator,
3634
private readonly ManagerRegistry $managerRegistry,
3735
private readonly LoggerInterface $logger,
3836
private readonly string $usernamePath = 'username',
@@ -69,7 +67,7 @@ public function onAuthenticationSuccess(Request $request, TokenInterface $token,
6967
return new RedirectResponse($targetPath);
7068
}
7169

72-
return new RedirectResponse($this->urlGenerator->generate('adminHomePage'));
70+
return new RedirectResponse($this->getDefaultSuccessPath($request));
7371
}
7472

7573
public function onAuthenticationFailure(Request $request, AuthenticationException $exception): Response
@@ -84,10 +82,9 @@ public function onAuthenticationFailure(Request $request, AuthenticationExceptio
8482
return parent::onAuthenticationFailure($request, $exception);
8583
}
8684

87-
protected function getLoginUrl(Request $request): string
88-
{
89-
return $this->urlGenerator->generate(self::LOGIN_ROUTE);
90-
}
85+
abstract protected function getLoginUrl(Request $request): string;
86+
87+
abstract protected function getDefaultSuccessPath(Request $request): string;
9188

9289
/**
9390
* @return array<'username'|'password', string>

0 commit comments

Comments
 (0)