Merge branch 'master' of git@github.com:openlibrary/bookreader into browserlending
[bookreader.git] / BookReaderIA / datanode / BookReaderJSIA.php
index e38c2fa..f02a92e 100644 (file)
@@ -575,6 +575,12 @@ if (typeof(brConfig) != 'undefined') {
     } else if (brConfig['mode'] == 2) {
         br.mode = 2;      
     }
+    
+    if (typeof(brConfig["isAdmin"]) != 'undefined') {
+        br.isAdmin = brConfig["isAdmin"];
+    } else {
+        br.isAdmin = false;
+    }
 } // brConfig
 
 
@@ -637,22 +643,34 @@ OLAuth.prototype.setPopupMsg = function(msg, resolution) {
     this.popup.innerHTML = ['<p><strong>', msg, '</strong></p><p>', resolution, '</p>'].join('\n');
 }
 
+OLAuth.prototype.showError = function(msg, resolution) {
+   $(this.popup).css({
+        backgroundColor: "#fff",
+        color: "#000"
+    });
+
+    this.setPopupMsg(msg, resolution);
+}
+
 OLAuth.prototype.initCallback = function(obj) {
     if (false == obj.success) {
-        $(this.popup).css({
-            backgroundColor: "#fff",
-            color: "#000"
-        });
-
-        this.setPopupMsg(obj.msg, obj.resolution);
-        return;
+        if (br.isAdmin) {
+            ret = confirm("We couldn't authenticate your loan with Open Library, but since you are an administrator or uploader of this book, you can access this book for QA purposes. Would you like to QA this book?");
+            if (!ret) {
+                this.showError(obj.msg, obj.resolution)
+            } else {
+                br.init();
+            }
+        } else {
+            this.showError(obj.msg, obj.resolution)
+        }       
+    } else {    
+        //user is authenticated
+        this.setCookie(obj.token);
+        this.olConnect = true;
+        this.startPolling();    
+        br.init();
     }
-    
-    //user is authenticated
-    this.setCookie(obj.token);
-    this.olConnect = true;
-    this.startPolling();    
-    br.init();
 }
 
 OLAuth.prototype.callback = function(obj) {