Bug 10240: (follow-up) don't delete transactions if auth fails
authorJared Camins-Esakov <jcamins@cpbibliography.com>
Wed, 10 Jul 2013 19:51:50 +0000 (15:51 -0400)
committerGalen Charlton <gmc@esilibrary.com>
Fri, 11 Oct 2013 01:57:04 +0000 (01:57 +0000)
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 <bgkriegel@gmail.com>
Signed-off-by: Chris Cormack <chris@bigballofwax.co.nz>
Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com>
Signed-off-by: Galen Charlton <gmc@esilibrary.com>
koha-tmpl/intranet-tmpl/prog/en/modules/circ/offline.tt

index f2e4544..608db2a 100644 (file)
@@ -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);
+                });
+            }
         });
     });