From 19ef90176823ea2d019dd4d3e4e2d403c605e94f Mon Sep 17 00:00:00 2001 From: Dane Everitt Date: Tue, 11 Jun 2019 23:19:43 -0700 Subject: [PATCH] Show success message to the user --- app/Http/Controllers/Auth/ForgotPasswordController.php | 5 +++-- resources/scripts/api/auth/requestPasswordResetEmail.ts | 4 ++-- .../scripts/components/auth/ForgotPasswordContainer.tsx | 7 +++---- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/app/Http/Controllers/Auth/ForgotPasswordController.php b/app/Http/Controllers/Auth/ForgotPasswordController.php index cb02cfc2c..e772321f9 100644 --- a/app/Http/Controllers/Auth/ForgotPasswordController.php +++ b/app/Http/Controllers/Auth/ForgotPasswordController.php @@ -33,10 +33,11 @@ class ForgotPasswordController extends Controller /** * Get the response for a successful password reset link. * - * @param string $response + * @param \Illuminate\Http\Request $request + * @param string $response * @return \Illuminate\Http\JsonResponse */ - protected function sendResetLinkResponse($response): JsonResponse + protected function sendResetLinkResponse(Request $request, $response): JsonResponse { return response()->json([ 'status' => trans($response), diff --git a/resources/scripts/api/auth/requestPasswordResetEmail.ts b/resources/scripts/api/auth/requestPasswordResetEmail.ts index f456560bb..d70139899 100644 --- a/resources/scripts/api/auth/requestPasswordResetEmail.ts +++ b/resources/scripts/api/auth/requestPasswordResetEmail.ts @@ -1,9 +1,9 @@ import http from '@/api/http'; -export default (email: string): Promise => { +export default (email: string): Promise => { return new Promise((resolve, reject) => { http.post('/auth/password', { email }) - .then(() => resolve()) + .then(response => resolve(response.data.status || '')) .catch(reject); }); }; diff --git a/resources/scripts/components/auth/ForgotPasswordContainer.tsx b/resources/scripts/components/auth/ForgotPasswordContainer.tsx index dfea4f38b..89e811ed6 100644 --- a/resources/scripts/components/auth/ForgotPasswordContainer.tsx +++ b/resources/scripts/components/auth/ForgotPasswordContainer.tsx @@ -33,13 +33,12 @@ class ForgotPasswordContainer extends React.PureComponent { this.setState({ isSubmitting: true }, () => { this.props.clearAllFlashMessages(); requestPasswordResetEmail(this.state.email) - .then(() => { - // @todo actually handle this. - }) + .then(response => this.props.pushFlashMessage({ + type: 'success', title: 'Success', message: response, + })) .catch(error => { console.error(error); this.props.pushFlashMessage({ - id: 'auth:forgot-password', type: 'error', title: 'Error', message: httpErrorToHuman(error),