-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
LoginLink create get Request Locale #40641
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Thanks for the follow-up @roromix. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you.
You are the best. Writing docs and patching bugs.
I agree with this PR and I do like the changes in LoginLinkHandler
. But you need to update the test. I will pass even without any modifications to LoginLinkHandler
.
If I copy the tests you written (without the changes in |
Sorry, i have no idea how to do that. Need help |
Here is a patch covering this change: diff --git a/src/Symfony/Component/Security/Http/Tests/LoginLink/LoginLinkHandlerTest.php b/src/Symfony/Component/Security/Http/Tests/LoginLink/LoginLinkHandlerTest.php
index 03dd0287d7..12b8f7da4a 100644
--- a/src/Symfony/Component/Security/Http/Tests/LoginLink/LoginLinkHandlerTest.php
+++ b/src/Symfony/Component/Security/Http/Tests/LoginLink/LoginLinkHandlerTest.php
@@ -69,7 +69,12 @@ class LoginLinkHandlerTest extends TestCase
if ($request) {
$this->router->expects($this->once())
->method('getContext')
- ->willReturn(new RequestContext());
+ ->willReturn($currentRequestContext = new RequestContext());
+
+ $this->router
+ ->expects($this->exactly(2))
+ ->method('setContext')
+ ->withConsecutive([$this->equalTo((new RequestContext())->fromRequest($request)->setParameter('_locale', $request->getLocale()))], [$currentRequestContext]);
}
$loginLink = $this->createLinker([], array_keys($extraProperties))->createLoginLink($user, $request);
@@ -78,19 +83,15 @@ class LoginLinkHandlerTest extends TestCase
public function provideCreateLoginLinkData()
{
- $request = Request::create('https://example.com');
- $request->setLocale('en');
-
yield [
new TestLoginLinkHandlerUser('weaverryan', 'ryan@symfonycasts.com', 'pwhash'),
['emailProperty' => 'ryan@symfonycasts.com', 'passwordProperty' => 'pwhash'],
- $request,
+ Request::create('https://example.com'),
];
yield [
new TestLoginLinkHandlerUser('weaverryan', 'ryan@symfonycasts.com', 'pwhash'),
['emailProperty' => 'ryan@symfonycasts.com', 'passwordProperty' => 'pwhash'],
- Request::create('https://example.com'),
];
yield [ |
I still have a lot to learn about the Tests |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you
Thank you @roromix. |
This PR was squashed before being merged into the 5.3-dev branch. Discussion ---------- [Security] Customize generated Login Link Fix #15147 and add documentation for symfony/symfony#40641 Commits ------- 830b1f3 [Security] Customize generated Login Link
While writing the documentation for PR#40153 I noticed that the RequestContext :: fromRequest method does not add the '_locale' parameter automaticaly. This new pull request to set _locale parameter to the RequestContext.