Skip to content

Commit 9d42569

Browse files
jasonvargaclaude
andcommitted
Remove now-dead error response path
After password reset responses are normalized to always succeed, the failure path in sendResetLinkFailedResponse is unreachable with the default broker. Drop it along with the obsolete external-URL test that relied on it. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 19d6085 commit 9d42569

2 files changed

Lines changed: 5 additions & 54 deletions

File tree

src/Auth/SendsPasswordResetEmails.php

Lines changed: 5 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -37,24 +37,12 @@ public function sendResetLinkEmail(Request $request)
3737
{
3838
$this->validateEmail($request);
3939

40-
// We will send the password reset link to this user. Once we have attempted
41-
// to send the link, we will examine the response then see the message we
42-
// need to show to the user. Finally, we'll send out a proper response.
43-
$response = $this->broker()->sendResetLink(
44-
$this->credentials($request)
45-
);
40+
// Always return the generic "reset link sent" response regardless of the broker's
41+
// actual result. INVALID_USER and RESET_THROTTLED would each reveal whether the
42+
// email belongs to a registered account (the broker only throttles real users).
43+
$this->broker()->sendResetLink($this->credentials($request));
4644

47-
// Treat "no such user" and "throttled" the same as a successful send so the
48-
// response does not reveal whether the email belongs to a registered account.
49-
// The broker only throttles real users, so a throttled response would itself
50-
// be an enumeration oracle.
51-
if (in_array($response, [Password::INVALID_USER, Password::RESET_THROTTLED], true)) {
52-
$response = Password::RESET_LINK_SENT;
53-
}
54-
55-
return $response === Password::RESET_LINK_SENT
56-
? $this->sendResetLinkResponse($request, $response)
57-
: $this->sendResetLinkFailedResponse($request, $response);
45+
return $this->sendResetLinkResponse($request, Password::RESET_LINK_SENT);
5846
}
5947

6048
/**
@@ -105,31 +93,6 @@ protected function sendResetLinkResponse(Request $request, $response)
10593
: $redirect->with('status', trans($response));
10694
}
10795

108-
/**
109-
* Get the response for a failed password reset link.
110-
*
111-
* @param string $response
112-
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Http\JsonResponse
113-
*/
114-
protected function sendResetLinkFailedResponse(Request $request, $response)
115-
{
116-
$errorRedirect = $request->input('_error_redirect');
117-
118-
$redirect = $errorRedirect && ! URL::isExternalToApplication($errorRedirect)
119-
? redirect($errorRedirect)
120-
: back();
121-
122-
if ($request->wantsJson()) {
123-
throw ValidationException::withMessages([
124-
'email' => [trans($response)],
125-
]);
126-
}
127-
128-
return $redirect
129-
->withInput($request->only('email'))
130-
->withErrors(['email' => trans($response)], 'user.forgot_password');
131-
}
132-
13396
/**
13497
* Get the broker to be used during password reset.
13598
*

tests/Tags/User/ForgotPasswordFormTest.php

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -273,18 +273,6 @@ public function it_wont_follow_redirect_to_external_url()
273273
->assertLocation('/forgot-password');
274274
}
275275

276-
#[Test]
277-
public function it_wont_follow_redirect_to_external_url_on_error()
278-
{
279-
$this
280-
->from('/forgot-password')
281-
->post('/!/auth/password/email', [
282-
'email' => 'not-an-email',
283-
'_error_redirect' => 'https://external-site.com/phishing',
284-
])
285-
->assertLocation('/forgot-password');
286-
}
287-
288276
#[Test]
289277
public function it_will_use_redirect_query_param_off_url()
290278
{

0 commit comments

Comments
 (0)