Skip to content

Conversation

@tijsverkoyen
Copy link
Member

@tijsverkoyen tijsverkoyen commented Aug 28, 2025

Pass the locale in the app:user:create console command.
With this the email can be send.

Summary by Sourcery

Pass the user's locale throughout account creation and confirmation flows to enable sending localized confirmation emails.

New Features:

  • Add an optional locale argument to the app:user:create console command and include it in the CreateUser message.
  • Propagate HTTP request locale from AddUser, RequestConfirmation, and ResendConfirmation controllers into the SendConfirmation message.
  • Extend SendConfirmation message, UserDataTransferObject, and message handlers to carry locale and generate confirmation links with the correct locale.

Enhancements:

  • Update SendConfirmationHandler to include the locale when generating the confirmation URL.

@sourcery-ai
Copy link

sourcery-ai bot commented Aug 28, 2025

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

This PR integrates locale propagation into user creation and confirmation workflows by extending controllers, commands, message classes, DTOs, and handlers to pass and use the locale for sending localized confirmation emails.

File-Level Changes

Change Details Files
Controllers now pass request locale when dispatching confirmation messages
  • Added Request argument to action methods
  • Extracted locale via request->getLocale()
  • Modified messageBus dispatch calls to include locale
src/Controller/User/Admin/RequestConfirmationController.php
src/Controller/User/Admin/AddUserController.php
src/Controller/User/ResendConfirmationController.php
CLI CreateCommand supports a locale argument
  • Introduced locale argument with default 'en'
  • Assigned locale to CreateUser message
src/Command/User/CreateCommand.php
UserDataTransferObject includes locale field
  • Added public string $locale property
src/DataTransferObject/User/UserDataTransferObject.php
SendConfirmation message now carries locale
  • Extended constructor to accept locale
src/Message/User/SendConfirmation.php
Message handlers propagate and apply locale
  • CreateUserHandler dispatches SendConfirmation with message.locale
  • RegisterUserHandler dispatches SendConfirmation with message.locale
  • SendConfirmationHandler adds _locale to route generation
src/MessageHandler/User/CreateUserHandler.php
src/MessageHandler/User/RegisterUserHandler.php
src/MessageHandler/User/SendConfirmationHandler.php

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey there - I've reviewed your changes and they look great!

Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments

### Comment 1
<location> `src/MessageHandler/User/SendConfirmationHandler.php:48` </location>
<code_context>
                 'confirmationLink' => $this->router->generate(
                     'user_confirm',
                     [
+                        '_locale' => $message->locale,
                         'token' => $user->getConfirmationToken(),
                     ],
</code_context>

<issue_to_address>
Passing locale in the confirmation link may expose internal details.

Validate the locale value before including it in URLs to prevent potential spoofing or exposure of sensitive information.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

'confirmationLink' => $this->router->generate(
'user_confirm',
[
'_locale' => $message->locale,
Copy link

Choose a reason for hiding this comment

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

🚨 suggestion (security): Passing locale in the confirmation link may expose internal details.

Validate the locale value before including it in URLs to prevent potential spoofing or exposure of sensitive information.

@tijsverkoyen tijsverkoyen requested a review from absumo September 5, 2025 08:18
@tijsverkoyen tijsverkoyen merged commit 1ac0c8f into main Sep 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants