Change the login js logic in the login.js. make it can work now
authorzhouruiyu <zhouruiyu@huawei.com>
Tue, 1 Nov 2016 06:48:16 +0000 (14:48 +0800)
committerzhouruiyu <zhouruiyu@huawei.com>
Tue, 1 Nov 2016 06:48:16 +0000 (14:48 +0800)
https://jira.open-o.org/browse/OCS-130

Change-Id: I0ae3fad366afeb67d1bed71a63f48f19eab8b13b
Signed-off-by: zhouruiyu <zhouruiyu@huawei.com>
openo-portal/portal-common/src/main/webapp/common/js/login.js

index d129b92..61d96b5 100644 (file)
@@ -29,13 +29,22 @@ function loginSubmitHandler() {
                url : "/openoapi/auth/v1/tokens",
                type : "POST",
                contentType : 'application/json; charset=utf-8',
-               data : JSON.stringify(loginData),
-               success : function(data) {
-                       top.window.document.location.href = "default.html";
-               },
-               error : function(data) {
-                       top.window.document.location.href = "login.html";
+               data : JSON.stringify(loginData)
+       }).done(function(data) {
+               var topURL = top.window.document.location.href;
+               if (topURL.indexOf("?service") != -1) {
+                       top.window.document.location.href = decodeURIComponent(topURL.substring(topURL.indexOf("?service")+9));
+               } else {
+                       top.window.document.location.href = "/openoui/common/default.html";
+               }
+       }).fail(function(data) {
+               if (data.status == 401) {
+                       alert("the username or password is wrong.")
+                       // username or pasword is wrong.
+               } else {
+                       // system error.
                }
+               top.window.document.location.href = "/openoui/common/login.html";
        }); 
 };