From cbf7e3b11bfe1f7ecdf49d71f0945163a441d9b3 Mon Sep 17 00:00:00 2001 From: Jared Camins-Esakov Date: Wed, 10 Jul 2013 15:51:50 -0400 Subject: [PATCH] Bug 10240: (follow-up) don't delete transactions if auth fails When uploading transactions, we were not checking that authentication had succeeded before deleting the transactions from the local database. That was bad. With this patch, we check. That is good. Signed-off-by: Bernardo Gonzalez Kriegel Signed-off-by: Chris Cormack Signed-off-by: Jonathan Druart Signed-off-by: Galen Charlton --- .../prog/en/modules/circ/offline.tt | 30 ++++++++++++------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/offline.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/offline.tt index f2e454408f..608db2a5a0 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/offline.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/offline.tt @@ -111,16 +111,26 @@ function synchronize() { $('#upload-transactions').click(function () { $('.loading-overlay div').text(_("Uploading transactions, please wait...")); $('.loading-overlay').show(); - var uploadIter = $.indexedDB("koha").objectStore("transactions").each(uploadTransaction); - uploadIter.done(function() { - $.indexedDB("koha").transaction(["transactions"]).then(function(){ - }, function(err, e){ - }, function(transaction){ - transaction.objectStore("transactions").clear(); - }); - $('.loading-overlay').hide(); - kohadb.saveSetting("dirty", false); - $('#upload-message').text(NO_UPLOAD_PENDING_MESSAGE); + $.ajax({ + type: "GET", + url: "/cgi-bin/koha/offline_circ/service.pl", + }).done(function (data) { + if (data) { + $('.loading-overlay').hide(); + alert(_("Please log in to Koha and try again. (Error: '" + data + "')")); + } else { + var uploadIter = $.indexedDB("koha").objectStore("transactions").each(uploadTransaction); + uploadIter.done(function() { + $.indexedDB("koha").transaction(["transactions"]).then(function(){ + }, function(err, e){ + }, function(transaction){ + transaction.objectStore("transactions").clear(); + }); + $('.loading-overlay').hide(); + kohadb.saveSetting("dirty", false); + $('#upload-message').text(NO_UPLOAD_PENDING_MESSAGE); + }); + } }); }); -- 2.39.5