Browse Source

resolve some bug

lusa 5 years ago
parent
commit
d80fd5e0df

+ 46 - 12
app/goahead-3.6.5/src/auth.c

@@ -25,7 +25,7 @@
 
 #include    "goahead.h"
 #include    "user.h"
-
+#include    "cJSON.h"
 #if ME_GOAHEAD_AUTH
 
 #if ME_COMPILER_HAS_PAM
@@ -535,23 +535,57 @@ static void loginServiceProc(Webs *wp)
     assert(wp);
     route = wp->route;
     assert(route);
-
+    char *pStr;
+    cJSON * root =  cJSON_CreateObject();
+    cJSON * data =  cJSON_CreateObject();
+    cJSON_AddItemToObject(root, "data", data);//根节点下添加
+    cJSON_AddStringToObject(root, "msg", "");
+    cJSON_AddNumberToObject(root, "code", 200);
     if (websLoginUser(wp, websGetVar(wp, "username", ""), websGetVar(wp, "password", ""))) {
         /* If the application defines a referrer session var, redirect to that */
         char *referrer;
-        if ((referrer = websGetSessionVar(wp, "referrer", 0)) != 0) {
-            websRedirect(wp, referrer);
-        } else {
-            websRedirectByStatus(wp, HTTP_CODE_OK);
-        }
+        // if ((referrer = websGetSessionVar(wp, "referrer", 0)) != 0) {
+        //     websRedirect(wp, referrer);
+        // } else {
+        //     websRedirectByStatus(wp, HTTP_CODE_OK);
+        // }
+
+         cJSON_AddNumberToObject(root, "code", 200);
+       
+        
+       
+
         websSetSessionVar(wp, "loginStatus", "ok");
     } else {
-        if (route->askLogin) {
-            (route->askLogin)(wp);
-        }
-        websSetSessionVar(wp, "loginStatus", "failed");
-        websRedirectByStatus(wp, HTTP_CODE_UNAUTHORIZED);
+        // if (route->askLogin) {
+        //     (route->askLogin)(wp);
+        // }
+        // websSetSessionVar(wp, "loginStatus", "failed");
+        // websRedirectByStatus(wp, HTTP_CODE_UNAUTHORIZED);
+         cJSON_AddNumberToObject(root, "code", 201);
     }
+
+     pStr = cJSON_PrintUnformatted(root);
+
+    printf("---> cJSON Str: %d \n%s\n", strlen(pStr), pStr);
+    websSetStatus(wp, 200);
+    websWriteHeaders(wp, -1, 0);    //Set length to -1 if unknown and transfer-chunk-encoding will be employed.
+    websWriteEndHeaders(wp);
+     int ret;
+    ret = websWrite(wp, "%s", pStr);
+    if(ret < 0)
+        printf("websWrite error\n");
+    
+    ret = websFlush(wp, 1); //wait for all data to be written to the socket 
+    if(ret != 1)
+        printf("websFlush error, ret = %d\n", ret);
+    
+    websDone(wp);
+
+    if(pStr)
+        wfree(pStr);
+    if(root)
+        cJSON_Delete(root);
 }
 
 

+ 1 - 1
app/goahead-3.6.5/src/utils/mine/ResultUtils.c

@@ -35,7 +35,7 @@ static void commResult(Webs *wp, int msgCode, int httpStatus, int isSuccess) {
     cJSON_AddItemToObject(root, "code", cJSON_CreateNumber(msgCode));
     cJSON_AddItemToObject(root, "isSuccess", cJSON_CreateNumber(isSuccess));
     
-    pStr = cJSON_Print(root);
+    pStr = cJSON_PrintUnformatted(root);
     
 
     // memcpy(cjson_str, pStr, strlen(pStr));

File diff suppressed because it is too large
+ 0 - 0
app/goahead-3.6.5/src/web/static/css/sensor_history.css


+ 1 - 1
app/goahead-3.6.5/src/web/static/css/setting.css

@@ -1 +1 @@
-input[data-v-408919c1]{margin:0}.subSection[data-v-408919c1]{padding:20px;width:450px}input[data-v-a5702e0a]{margin:0}.subSection[data-v-a5702e0a]{padding:20px}.col-sub[data-v-a5702e0a]{background-color:#fff;text-align:center;height:100px;display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-orient:vertical;-webkit-box-direction:normal;-ms-flex-direction:column;flex-direction:column;border-radius:8px;cursor:pointer}.col-sub span[data-v-a5702e0a]{margin-top:10px;font-weight:500}.col-sub i[data-v-a5702e0a]{margin-top:15px}
+input[data-v-408919c1]{margin:0}.subSection[data-v-408919c1]{padding:20px;width:450px}input[data-v-e8e2b548]{margin:0}.subSection[data-v-e8e2b548]{padding:20px}.col-sub[data-v-e8e2b548]{background-color:#fff;text-align:center;height:100px;display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-orient:vertical;-webkit-box-direction:normal;-ms-flex-direction:column;flex-direction:column;border-radius:8px;cursor:pointer}.col-sub span[data-v-e8e2b548]{margin-top:10px;font-weight:500}.col-sub i[data-v-e8e2b548]{margin-top:15px}

File diff suppressed because it is too large
+ 0 - 0
app/goahead-3.6.5/src/web/static/js/sensor_history.js


File diff suppressed because it is too large
+ 0 - 0
app/goahead-3.6.5/src/web/static/js/setting.js


+ 6 - 6
app/goahead-3.6.5/src/web_interface/src/fru.c

@@ -165,7 +165,7 @@ void getFruChassisInfo(Webs *wp)
     cJSON_AddStringToObject(data, "SN", _chassisSerialNum);
     cJSON_AddStringToObject(data, "OEM", _chassisCustomField);
 
-    pStr = cJSON_Print(root);
+    pStr = cJSON_PrintUnformatted(root);
     
     websSetStatus(wp, 200);
     websWriteHeaders(wp, -1, 0);	//Set length to -1 if unknown and transfer-chunk-encoding will be employed.
@@ -295,7 +295,7 @@ void getFruBoardInfo(Webs *wp)
     cJSON_AddStringToObject(data, "PN", _boardPartNum);
     cJSON_AddStringToObject(data, "OEM", _boardCustomField);
 
-    pStr = cJSON_Print(root);
+    pStr = cJSON_PrintUnformatted(root);
     
     websSetStatus(wp, 200);
     websWriteHeaders(wp, -1, 0);	//Set length to -1 if unknown and transfer-chunk-encoding will be employed.
@@ -434,7 +434,7 @@ void getFruProductInfo(Webs *wp)
     cJSON_AddStringToObject(data, "Ver", _ProductVersion);
     cJSON_AddStringToObject(data, "SN", _ProductSerialNum);
     cJSON_AddStringToObject(data, "OEM", _productCustomField);
-    pStr = cJSON_Print(root);
+    pStr = cJSON_PrintUnformatted(root);
     
     websSetStatus(wp, 200);
     websWriteHeaders(wp, -1, 0);	//Set length to -1 if unknown and transfer-chunk-encoding will be employed.
@@ -758,9 +758,9 @@ void getFruProductInfo(Webs *wp)
 //     cJSON_AddStringToObject(product, "SN", _ProductSerialNum);
 //     cJSON_AddStringToObject(product, "OEM", _productCustomField);
 
-//     pStr1 = cJSON_Print(chassis);
-//     pStr2 = cJSON_Print(board);
-//     pStr3 = cJSON_Print(product);
+//     pStr1 = cJSON_PrintUnformatted(chassis);
+//     pStr2 = cJSON_PrintUnformatted(board);
+//     pStr3 = cJSON_PrintUnformatted(product);
     
 //     websSetStatus(wp, 200);
 //     websWriteHeaders(wp, -1, 0);	//Set length to -1 if unknown and transfer-chunk-encoding will be employed.

+ 2 - 2
app/goahead-3.6.5/src/web_interface/src/remote_control.c

@@ -67,7 +67,7 @@ void chassisPwrCtrl(Webs *wp){
 		cJSON_AddStringToObject(data, "status", "fail");
 	}
 
-    pStr = cJSON_Print(root);
+    pStr = cJSON_PrintUnformatted(root);
 
     printf("---> cJSON Str: %d\n%s\n", strlen(pStr), pStr);
     websSetStatus(wp, 200);
@@ -118,7 +118,7 @@ void getChassisStatus(Webs *wp)
     	cJSON_AddStringToObject(data, "powerStatus", "on" );	
     }
 
-    pStr = cJSON_Print(root);
+    pStr = cJSON_PrintUnformatted(root);
 
     printf("---> cJSON Str: %d \n%s\n", strlen(pStr), pStr);
     websSetStatus(wp, 200);

+ 1 - 3
gd32450i-eval.initramfs

@@ -144,7 +144,7 @@ file /etc/goahead/self.key ${INSTALL_ROOT}/projects/${SAMPLE}/app/goahead-3.6.5/
 file /etc/goahead/auth.txt ${INSTALL_ROOT}/projects/${SAMPLE}/app/goahead-3.6.5/src/auth.txt 755 0 0
 file /etc/goahead/route.txt ${INSTALL_ROOT}/projects/${SAMPLE}/app/goahead-3.6.5/src/route.txt 755 0 0
 
-le /var/www/goahead/favicon.ico ${INSTALL_ROOT}/projects/${SAMPLE}/app/goahead-3.6.5/src/web/favicon.ico 755 0 0
+file /var/www/goahead/favicon.ico ${INSTALL_ROOT}/projects/${SAMPLE}/app/goahead-3.6.5/src/web/favicon.ico 755 0 0
 file /var/www/goahead/index.html ${INSTALL_ROOT}/projects/${SAMPLE}/app/goahead-3.6.5/src/web/index.html 755 0 0
 file /var/www/goahead/static/css/app.css ${INSTALL_ROOT}/projects/${SAMPLE}/app/goahead-3.6.5/src/web/static/css/app.css 755 0 0
 file /var/www/goahead/static/css/chunk-vendors.css ${INSTALL_ROOT}/projects/${SAMPLE}/app/goahead-3.6.5/src/web/static/css/chunk-vendors.css 755 0 0
@@ -203,5 +203,3 @@ file /var/www/goahead/static/js/system_logs.js ${INSTALL_ROOT}/projects/${SAMPLE
 file /var/www/goahead/static/js/UploadProgre.js ${INSTALL_ROOT}/projects/${SAMPLE}/app/goahead-3.6.5/src/web/static/js/UploadProgre.js 755 0 0
 file /var/www/goahead/static/js/UserManage.js ${INSTALL_ROOT}/projects/${SAMPLE}/app/goahead-3.6.5/src/web/static/js/UserManage.js 755 0 0
 
-
-

Some files were not shown because too many files changed in this diff