From 44f1de1b2679e53dfbdf195892aa233ff2ca7570 Mon Sep 17 00:00:00 2001 From: Frederic Junod Date: Thu, 7 Mar 2019 15:50:50 +0100 Subject: [PATCH] Fix message type binding with bind --- contribs/gmf/src/authentication/component.js | 43 ++++++++++---------- 1 file changed, 22 insertions(+), 21 deletions(-) diff --git a/contribs/gmf/src/authentication/component.js b/contribs/gmf/src/authentication/component.js index 02d4243218d9..fa8f460f32a1 100644 --- a/contribs/gmf/src/authentication/component.js +++ b/contribs/gmf/src/authentication/component.js @@ -347,10 +347,13 @@ class AuthenticationController { if (errors.length) { this.setError_(errors); } else { - const error = gettextCatalog.getString('Incorrect credentials or disabled account.'); - this.gmfAuthenticationService_.login(this.loginVal, this.pwdVal).then( - this.resetError_.bind(this), - this.setError_.bind(this, error)); + this.gmfAuthenticationService_.login(this.loginVal, this.pwdVal) + .then(() => { + this.resetError_(); + }) + .catch(() => { + this.setError_(gettextCatalog.getString('Incorrect credentials or disabled account.')); + }); } } @@ -359,10 +362,13 @@ class AuthenticationController { */ logout() { const gettextCatalog = this.gettextCatalog; - const error = gettextCatalog.getString('Could not log out.'); - this.gmfAuthenticationService_.logout().then( - this.resetError_.bind(this), - this.setError_.bind(this, error)); + this.gmfAuthenticationService_.logout() + .then(() => { + this.resetError_(); + }) + .catch(() => { + this.setError_(gettextCatalog.getString('Could not log out.')); + }); } /** @@ -376,20 +382,15 @@ class AuthenticationController { return; } - const error = gettextCatalog.getString('An error occurred while resetting the password.'); - - /** - * @param {import('gmf/authentication/Service.js').AuthenticationDefaultResponse} respData Response. - */ - const resetPasswordSuccessFn = function(respData) { - this.resetPasswordModalShown = true; - this.resetError_(); - }.bind(this); + this.gmfAuthenticationService_.resetPassword(this.loginVal) + .then(() => { + this.resetPasswordModalShown = true; + this.resetError_(); + }) + .catch(() => { + this.setError_(gettextCatalog.getString('An error occurred while resetting the password.')); + }); - this.gmfAuthenticationService_.resetPassword(this.loginVal).then( - resetPasswordSuccessFn, - this.setError_.bind(this, error) - ); }