| Total Complexity | 2 |
| Total Lines | 27 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 11 | class PasswordResetLinkController extends Controller |
||
| 12 | { |
||
| 13 | /** |
||
| 14 | * Handle an incoming password reset link request. |
||
| 15 | * |
||
| 16 | * @throws \Illuminate\Validation\ValidationException |
||
| 17 | */ |
||
| 18 | public function store(Request $request): JsonResponse |
||
| 19 | { |
||
| 20 | $request->validate([ |
||
| 21 | 'email' => ['required', 'email'], |
||
| 22 | ]); |
||
| 23 | |||
| 24 | // We will send the password reset link to this user. Once we have attempted |
||
| 25 | // to send the link, we will examine the response then see the message we |
||
| 26 | // need to show to the user. Finally, we'll send out a proper response. |
||
| 27 | $status = Password::broker('{{pluralSlug}}')->sendResetLink( |
||
| 28 | $request->only('email') |
||
| 29 | ); |
||
| 30 | |||
| 31 | if ($status != Password::RESET_LINK_SENT) { |
||
| 32 | throw ValidationException::withMessages([ |
||
| 33 | 'email' => [__($status)], |
||
| 34 | ]); |
||
| 35 | } |
||
| 36 | |||
| 37 | return response()->json(['status' => __($status)]); |
||
| 38 | } |
||
| 40 |