Skip to content

[New routing] Refactoring verify shop user#18879

Open
loic425 wants to merge 3 commits intoSylius:new-routingfrom
loic425:verify-shop-user
Open

[New routing] Refactoring verify shop user#18879
loic425 wants to merge 3 commits intoSylius:new-routingfrom
loic425:verify-shop-user

Conversation

@loic425
Copy link
Copy Markdown
Member

@loic425 loic425 commented Feb 26, 2026

Q A
Branch? new-routing
Bug fix? no
New feature? yes
BC breaks? no
Deprecations? no
Related tickets partially #18212
License MIT

@loic425 loic425 requested review from a team as code owners February 26, 2026 19:57
@probot-autolabeler probot-autolabeler bot added the Shop ShopBundle related issues and PRs. label Feb 26, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Feb 26, 2026

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 1faee830-b615-4472-a41c-00fc90b24724

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Tip

Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs).
Share your feedback on Discord.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions
Copy link
Copy Markdown

github-actions bot commented Feb 26, 2026

❗ Preview Environment deployment failed on Bunnyshell

See: Environment Details | Pipeline Logs

Check https://github.com/Sylius/Sylius/actions/runs/22486940304 for details.

Available commands:

  • 🚀 /bns:deploy to redeploy the environment
  • /bns:delete to remove the environment

@loic425 loic425 force-pushed the verify-shop-user branch 3 times, most recently from 464301f to 006bf6d Compare February 27, 2026 08:43

namespace Sylius\Bundle\CoreBundle\CommandHandler\Shop\Account;

use InvalidArgumentException;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
use InvalidArgumentException;

Comment on lines +16 to +34
use Sylius\Bundle\CoreBundle\Command\Shop\Account\VerifyShopUser;
use Sylius\Bundle\CoreBundle\CommandDispatcher\ResetPasswordDispatcherInterface;
use Sylius\Bundle\CoreBundle\Provider\FlashBagProvider;
use Sylius\Bundle\UserBundle\Form\Model\PasswordReset;
use Sylius\Bundle\UserBundle\Form\Type\UserResetPasswordType;
use Sylius\Component\Channel\Context\ChannelContextInterface;
use Sylius\Component\Locale\Context\LocaleContextInterface;
use Sylius\Component\User\Model\UserInterface;
use Sylius\Component\User\Repository\UserRepositoryInterface;
use Symfony\Component\Form\FormFactoryInterface;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Symfony\Component\Messenger\MessageBusInterface;
use Symfony\Component\Routing\RouterInterface;
use Symfony\Contracts\Translation\TranslatorInterface;
use Twig\Environment;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some of these aren't used at all

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@loic425 loic425 force-pushed the verify-shop-user branch 2 times, most recently from 8833ef1 to 1835a6c Compare February 27, 2026 12:44
Co-authored-by: Jan Góralski <jan.wojciech.goralski@gmail.com>
@loic425
Copy link
Copy Markdown
Member Author

loic425 commented Feb 27, 2026

@NoResponseMate Flash messages are already translated in the UI.

<div {{ sylius_test_html_attribute('flash-messages') }}>
    {% if flash is iterable %}
        {{ flash.message|trans(flash.parameters, 'flashes') }}
    {% else %}
        {{ flash|trans({}, 'flashes') }}
    {% endif %}
</div>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be cool to sync arguments order between VerifyShopUser and SendAccountRegistrationEmail and future commands.

Right now it's like so, but putting subject on first line and channelCode, localeCode in this order would look better.

---       public readonly string $shopUserEmail,
---       public readonly string $localeCode,
---       public readonly string $channelCode,
+++       public readonly string $channelCode,
+++       public readonly string $localeCode,
+++       public readonly string $token,

Comment on lines +22 to +24
public readonly string $shopUserEmail,
public readonly string $localeCode,
public readonly string $channelCode,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
public readonly string $shopUserEmail,
public readonly string $localeCode,
public readonly string $channelCode,
public readonly string $shopUserEmail,
public readonly string $channelCode,
public readonly string $localeCode,

Comment on lines +22 to +24
public readonly string $channelCode,
public readonly string $localeCode,
public readonly string $token,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
public readonly string $channelCode,
public readonly string $localeCode,
public readonly string $token,
public readonly string $token,
public readonly string $channelCode,
public readonly string $localeCode,

use Symfony\Component\Messenger\Attribute\AsMessageHandler;

#[AsMessageHandler]
final class SendAccountRegistrationEmailHandler
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
final class SendAccountRegistrationEmailHandler
final readonly class SendAccountRegistrationEmailHandler

Comment on lines +38 to +42
if (null === $shopUser) {
throw new \InvalidArgumentException(
sprintf('There is no shop user with %s email', $command->shopUserEmail),
);
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not use Assert as usual?

Suggested change
if (null === $shopUser) {
throw new \InvalidArgumentException(
sprintf('There is no shop user with %s email', $command->shopUserEmail),
);
}
Assert::notNull($shopUser, sprintf('There is no shop user with %s email', $command->shopUserEmail));

Comment on lines +46 to +50
if (null === $channel) {
throw new \InvalidArgumentException(
sprintf('There is no channel with %s code', $command->channelCode),
);
}
Copy link
Copy Markdown
Member

@diimpp diimpp Mar 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assert usage would be shorter.

return;
}

$this->accountRegistrationEmailManager->sendAccountRegistrationEmail($shopUser, $channel, $command->localeCode);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing check, that localeCode matches provided channel.

Comment on lines +40 to +44
if (null === $user) {
throw new \InvalidArgumentException(
sprintf('There is no shop user with %s email verification token', $command->token),
);
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assert would be shorter

$user->enable();

$this->commandBus->dispatch(
new SendAccountRegistrationEmail($user->getEmail(), $command->localeCode, $command->channelCode),
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's okay to skip channelCode/localeCode asserts as long as SendAccountRegistrationEmail checks them.

Copy link
Copy Markdown
Member

@diimpp diimpp Mar 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P.S. We should dispatch events, like ShopUserVerified, not hardcode command calls.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Shop ShopBundle related issues and PRs.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants