2016-11-03 81 views
0

我有這個錯誤爲什麼要登錄到我的科爾多瓦/ Ionic應用程序。Cordova身份驗證

Cannot read property 'error_description' of undefined 
TypeError: Cannot read property 'error_description' of undefined 
at http://localhost:8000/js/services/Authentication.js:39:32 
at processQueue (http://localhost:8000/lib/ionic/js/ionic.bundle.js:21888:27) 
at http://localhost:8000/lib/ionic/js/ionic.bundle.js:21904:27 
at Scope.$eval (http://localhost:8000/lib/ionic/js/ionic.bundle.js:23100:28) 
at Scope.$digest (http://localhost:8000/lib/ionic/js/ionic.bundle.js:22916:31) 
at ChildScope.$apply (http://localhost:8000/lib/ionic/js/ionic.bundle.js:23205:24) 
at HTMLFormElement.<anonymous> (http://localhost:8000/lib/ionic/js/ionic.bundle.js:30139:23) 
at HTMLFormElement.dispatch (http://localhost:8000/lib/jquery/dist/jquery.js:4430:9) 
at HTMLFormElement.elemData.handle (http://localhost:8000/lib/jquery/dist/jquery.js:4116:28) 
at triggerMouseEvent (http://localhost:8000/lib/ionic/js/ionic.bundle.js:2863:7) 

我需要知道,做我的登錄名/密碼是錯誤的,或者只是我的應用程序不能正常工作

認證相關的代碼是

  doLogin:   function (username, password) { 
return ServerAPI.logIn({}, {Username: username, Password: password, Version: AppConstants.Build, grant_type: "password"}).$promise 
     .then(function (response) { 
     if (!response.error) { 
      authService.loginCancelled({}); 
      currentUser.isAuthenticated = !response.error; 
      currentUser.data = response; 
      currentUser.data.UserId = response.currentUserId; 
      currentUser.data.UserName = username; 
      currentUser.UserId = response.currentUserId; 
      currentUser.lastloggedinTimestamp = (new Date()).getTime(); 
      // Saves session data into database so it can be accessed after app reopened 
      Database.insertInto('Session', currentUser.UserId, currentUser, {}); 
      // Saves the session data into a cookie so the request interceptor can access it 
      Session.put('emInspectionUser', currentUser); 
      authService.loginConfirmed(currentUser); 
     } 
     else { 
      Session.remove('emInspectionUser'); 
     } 
     return response; 
     }, function (error) { 
     if (error.status === 0) { 
      return $q.reject('Could not connect to server.\nPlease check your network connection.'); 
     } 
     else if (error.data.error_description) { 
      return $q.reject(error.data.error_description); 
     } 
     return $q.reject(error.status + ': ' + error.statusText); 
     }); 

我正在科爾多瓦應用程序和我已登錄並通過,但我不確定我的登錄和傳球是否正確,並且由於此錯誤,我無法測試。

回答

0

你可以寫你否則,如果條件如下

else if (error.data.hasOwnProperty(error_description)) { 
    return $q.reject(error.data.error_description); 
} 
+0

沒有什麼改變了 –