Skip to content

Commit

Permalink
Merge pull request #4725 from camptocamp/GSGMF-827
Browse files Browse the repository at this point in the history
Fix message type binding with bind
  • Loading branch information
fredj committed Mar 7, 2019
2 parents d425f57 + 44f1de1 commit 60635fa
Showing 1 changed file with 22 additions and 21 deletions.
43 changes: 22 additions & 21 deletions contribs/gmf/src/authentication/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.'));
});
}
}

Expand All @@ -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.'));
});
}

/**
Expand All @@ -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)
);
}


Expand Down

0 comments on commit 60635fa

Please sign in to comment.