Skip to content

Commit

Permalink
Merge pull request #1201 from LibraryOfCongress/captcha-bug-fix
Browse files Browse the repository at this point in the history
Handle main form submission after successful captcha
  • Loading branch information
rstorey authored Mar 18, 2020
2 parents 64201af + aa9741d commit 6407d85
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions concordia/static/js/contribute.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ $(document).on('keydown', function(event) {
});

var $captchaModal = $('#captcha-modal');
var $triggeringCaptchaForm = false;
var $captchaForm = $captchaModal.find('form').on('submit', function(event) {
event.preventDefault();

Expand All @@ -56,6 +57,10 @@ var $captchaForm = $captchaModal.find('form').on('submit', function(event) {
})
.done(function() {
$captchaModal.modal('hide');
if ($triggeringCaptchaForm) {
$triggeringCaptchaForm.submit();
}
$triggeringCaptchaForm = false;
})
.fail(function(jqXHR) {
if (jqXHR.status == 401) {
Expand Down Expand Up @@ -115,15 +120,17 @@ $('form.ajax-submission').each(function(idx, formElement) {
$captchaModal
.find('#captcha-image')
.attr('src', jqXHR.responseJSON.image);
$triggeringCaptchaForm = $form;
$captchaModal.modal();
} else {
$form.trigger('form-submit-failure', {
textStatus: textStatus,
errorThrown: errorThrown,
requestData: formData,
$form: $form,
jqXHR: jqXHR
});
}
$form.trigger('form-submit-failure', {
textStatus: textStatus,
errorThrown: errorThrown,
requestData: formData,
$form: $form,
jqXHR: jqXHR
});
});

return false;
Expand Down

0 comments on commit 6407d85

Please sign in to comment.