diff --git a/app/Http/Controllers/Auth/ForgotPasswordController.php b/app/Http/Controllers/Auth/ForgotPasswordController.php index a4e35c54..8234e81d 100644 --- a/app/Http/Controllers/Auth/ForgotPasswordController.php +++ b/app/Http/Controllers/Auth/ForgotPasswordController.php @@ -52,7 +52,6 @@ protected function validateEmail(Request $request) protected function sendResetLinkResponse(Request $request, $response) { return ['status' => trans($response)]; - // return response()->json(['status' => $response], 200); } /** @@ -64,6 +63,6 @@ protected function sendResetLinkResponse(Request $request, $response) */ protected function sendResetLinkFailedResponse(Request $request, $response) { - return response()->json(['email' => trans($response)], 400); + return response()->json(['requestFailed' => trans($response)], 400); } } diff --git a/app/Http/Controllers/Auth/ResetPasswordController.php b/app/Http/Controllers/Auth/ResetPasswordController.php index 0676ce8b..64dd3d44 100644 --- a/app/Http/Controllers/Auth/ResetPasswordController.php +++ b/app/Http/Controllers/Auth/ResetPasswordController.php @@ -2,6 +2,7 @@ namespace App\Http\Controllers\Auth; +use Illuminate\Http\Request; use App\Http\Controllers\Controller; use Illuminate\Foundation\Auth\ResetsPasswords; @@ -51,6 +52,6 @@ protected function sendResetResponse(Request $request, $response) */ protected function sendResetFailedResponse(Request $request, $response) { - return response()->json(['email' => trans($response)], 400); + return response()->json(['resetFailed' => trans($response)], 400); } } diff --git a/resources/js/views/auth/password/Request.vue b/resources/js/views/auth/password/Request.vue index 8595c485..d32603f1 100644 --- a/resources/js/views/auth/password/Request.vue +++ b/resources/js/views/auth/password/Request.vue @@ -2,7 +2,7 @@
-

{{ $t('auth.reset_password') }}

+

{{ $t('auth.forms.reset_password') }}

@@ -13,13 +13,17 @@
- +
{{ $t('commons.cancel') }}
+
+ + {{ errorMessage }} +
@@ -37,13 +41,16 @@ return { email : '', validationErrors: {}, - response: '' + response: '', + errorMessage: '' } }, methods : { handleSubmit(e){ e.preventDefault() + this.validationErrors = {} + axios.post('/api/password/email', { email: this.email }) @@ -51,11 +58,11 @@ this.response = response.data.status }) .catch(error => { - console.log(error.response) if( error.response.data.errors ) { this.validationErrors = error.response.data.errors - } else if( error.response.data ) { - this.response = error.response.data.email + } + else if( error.response.data.requestFailed ) { + this.errorMessage = error.response.data.requestFailed } else { this.$router.push({ name: 'genericError', params: { err: error.response.data.message } }); diff --git a/resources/js/views/auth/password/Reset.vue b/resources/js/views/auth/password/Reset.vue index 32eb6938..c087faed 100644 --- a/resources/js/views/auth/password/Reset.vue +++ b/resources/js/views/auth/password/Reset.vue @@ -2,24 +2,24 @@
-

{{ $t('auth.new_password') }}

-
+

{{ $t('auth.forms.new_password') }}

+
- +

{{ validationErrors.email.toString() }}

- +

{{ validationErrors.password.toString() }}

- +
@@ -27,13 +27,17 @@
- +
{{ $t('commons.cancel') }}
+
+ + {{ errorMessage }} +
@@ -43,11 +47,12 @@ export default { data(){ return { - token : '', email : '', password : '', password_confirmation : '', - validationErrors: {} + token : '', + validationErrors: {}, + errorMessage: '' } }, @@ -60,26 +65,24 @@ handleSubmit(e) { e.preventDefault() - axios.post('api/password/reset', { + this.validationErrors = {} + + axios.post('/api/password/reset', { email: this.email, password: this.password, password_confirmation : this.password_confirmation, token: this.token }) .then(response => { - console.log(response) - // localStorage.setItem('user',response.data.message.name) - // localStorage.setItem('jwt',response.data.message.token) - - // if (localStorage.getItem('jwt') != null){ - // this.$router.go('/'); - // } + this.$router.go('/'); }) .catch(error => { - console.log(error.response) if( error.response.data.errors ) { this.validationErrors = error.response.data.errors } + else if( error.response.data.resetFailed ) { + this.errorMessage = error.response.data.resetFailed + } else { this.$router.push({ name: 'genericError', params: { err: error.response.data.message } }); }