Преглед изворни кода

login authentication changes

Naresh Ch пре 2 година
родитељ
комит
bdc98e7107
1 измењених фајлова са 10 додато и 4 уклоњено
  1. 10
    4
      assets/js/login.js

+ 10
- 4
assets/js/login.js Прегледај датотеку

@@ -75,11 +75,17 @@ function loginUser(email, password) {
75 75
   fetch(serverUrl + 'account/login', requestOptions)
76 76
     .then((response) => response.text())
77 77
     .then((result) => {
78
-      const user = JSON.parse(result);
79
-      setCookie('authentication', user.result.sessionId, 1);
80
-      window.location = '../authentication';
78
+      const data = JSON.parse(result);
79
+      if (data.status === 0) {
80
+        setCookie('authentication', data.result.sessionId, 1);
81
+        window.location = '../authentication';
82
+      } else {
83
+        passwordErrEl.innerText = data.message;
84
+      }
81 85
     })
82
-    .catch((error) => console.log('error', error));
86
+    .catch((error) => {
87
+      passwordErrEl.innerText = error;
88
+    });
83 89
 }
84 90
 
85 91
 function validateLogin() {

Loading…
Откажи
Сачувај