From bf003ebe0cde0f98e04889b52d2bdfb857f32567 Mon Sep 17 00:00:00 2001 From: Toby Zerner Date: Mon, 28 Mar 2016 15:46:20 +1030 Subject: [PATCH] Add specific error message when an email address is not found in forgot password modal --- framework/core/js/forum/dist/app.js | 12 +++++++++++- .../js/forum/src/components/ForgotPasswordModal.js | 11 ++++++++++- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/framework/core/js/forum/dist/app.js b/framework/core/js/forum/dist/app.js index 224781f32..a7ad0c813 100644 --- a/framework/core/js/forum/dist/app.js +++ b/framework/core/js/forum/dist/app.js @@ -22110,12 +22110,22 @@ System.register('flarum/components/ForgotPasswordModal', ['flarum/components/Mod app.request({ method: 'POST', url: app.forum.attribute('apiUrl') + '/forgot', - data: { email: this.email() } + data: { email: this.email() }, + errorHandler: this.onerror.bind(this) }).then(function () { _this2.success = true; _this2.alert = null; }).catch(function () {}).then(this.loaded.bind(this)); } + }, { + key: 'onerror', + value: function onerror(error) { + if (error.status === 404) { + error.alert.props.children = app.translator.trans('core.forum.forgot_password.not_found_message'); + } + + babelHelpers.get(Object.getPrototypeOf(ForgotPasswordModal.prototype), 'onerror', this).call(this, error); + } }]); return ForgotPasswordModal; }(Modal); diff --git a/framework/core/js/forum/src/components/ForgotPasswordModal.js b/framework/core/js/forum/src/components/ForgotPasswordModal.js index 673b07946..b590ccdc3 100644 --- a/framework/core/js/forum/src/components/ForgotPasswordModal.js +++ b/framework/core/js/forum/src/components/ForgotPasswordModal.js @@ -85,7 +85,8 @@ export default class ForgotPasswordModal extends Modal { app.request({ method: 'POST', url: app.forum.attribute('apiUrl') + '/forgot', - data: {email: this.email()} + data: {email: this.email()}, + errorHandler: this.onerror.bind(this) }) .then(() => { this.success = true; @@ -94,4 +95,12 @@ export default class ForgotPasswordModal extends Modal { .catch(() => {}) .then(this.loaded.bind(this)); } + + onerror(error) { + if (error.status === 404) { + error.alert.props.children = app.translator.trans('core.forum.forgot_password.not_found_message'); + } + + super.onerror(error); + } }