Skip to content

Instantly share code, notes, and snippets.

@cemeng
Created March 22, 2017 04:45
Show Gist options
  • Save cemeng/60ce07676b59842886500fe85455f198 to your computer and use it in GitHub Desktop.
Save cemeng/60ce07676b59842886500fe85455f198 to your computer and use it in GitHub Desktop.
Reset password handler
<script type='text/javascript'>
var resetPasswordHandler = new function() {
var that = this;
this.passwordResetSuccess = true;
this.errorCode = null;
this.errorDetails = null;
this.onError = function(eventObj) {
that.errorCode = eventObj.response.info.response.errorCode;
that.errorDetails = eventObj.response.info.response.errorDetails;
that.passwordResetSuccess = false;
}
this.onAfterSubmit = function(eventObj) {
if (that.passwordResetSuccess) {
window.location.href = '<%= @callback_uri.html_safe %>';
} else {
// setting the error here because the error message has not been rendered on onError event
if (that.errorCode === 400006 && that.errorDetails.indexOf('Reset password link expired') === 0) {
$('.gigya-error-code-400006.gigya-error-msg-active').html('Password token has expired or is invalid. Please make a new password reset request.');
}
}
}
}();
gigya.accounts.showScreenSet({
'screenSet': '<%= @channel.gigya_authentication_screenset %>',
'containerID': 'reset-password',
'startScreen': 'gigya-reset-password-screen',
'passwordResetToken': '<%= @token %>',
'onError': resetPasswordHandler.onError,
'onAfterSubmit': resetPasswordHandler.onAfterSubmit
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment