Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix message type binding with bind #4725

Merged
merged 1 commit into from
Mar 7, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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