Browse Source

错误处理

jason.lu 6 years ago
parent
commit
5484d6d60e
1 changed files with 13 additions and 1 deletions
  1. 13 1
      js/basic.js

+ 13 - 1
js/basic.js

@@ -141,11 +141,24 @@ function on_gp_success(a,b) {
 }
 
 function on_dat_success(a,b){
+    if(check_if_authfail(a,b)){
+        location.href = "sign-in1.html?from=entrance-1&msg=server-redirect-detected";
+        return;
+    }
     if(check_if_success(a,b)) {
         this.callme(a,b);
     }
 }
 
+function check_if_authfail(a){
+    if(a == null || typeof a !== "string"){
+        if(a.indexOf("login?from=") > 0 || a.startsWith("<!DOCTYPE html>") || a.indexOf("<!-- SME::LOGINPAGE -->") > 0){
+            return true;
+        }
+    }
+    return false;
+}
+
 function check_if_success(a,b){
     if(typeof a === "string"){
         try {
@@ -410,7 +423,6 @@ function getUserId() {
     try{
         var mm = parseInt(use);
         if(mm <= 0){
-            location.href = "sign-in1.html?from=entrance-1&msg=cookie-wrong-format";
         }else{
             userId = mm;
         }