Cordova身份验证
问题描述:
我有这个错误为什么要登录到我的科尔多瓦/ 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);
});
我正在科尔多瓦应用程序和我已登录并通过,但我不确定我的登录和传球是否正确,并且由于此错误,我无法测试。
答
你可以写你否则,如果条件如下
else if (error.data.hasOwnProperty(error_description)) {
return $q.reject(error.data.error_description);
}
没有什么改变了 –