我收到此错误 - ReferenceError:idhoken未在controllers.js:99处定义,即auth0-angular4.js:619。我的令牌会出现什么问题?
.controller('loginCtrl', function($scope, $firebaseObject, $firebaseAuth, $state, $timeout, Auth, store, $location, auth, $rootScope, jwtHelper) {
$scope.login = function() {
auth.signin({
authParams: {
scope: 'openid offline-access',
device: 'Mobile device'
}
}, function(profile, token, accessToken, state, refreshToken) {
store.set('store', profile);
store.set('token', idToken);
store.set('refreshToken', refreshToken);
auth.getToken({
api: 'firebase'
}).then(function(delegate) {
store.set('firebaseToken', delegate.id_token);
$state.go('tabsController.pendingTasks');
}, function(error) {
})
})
$rootScope.$on('$locationChangeStart', function() {
if (!auth.isAuthenticated) {
var token = store.get('token');
if (token) {
if (!jwtHelper.isTokenExpired(token)) {
auth.authenticate(store.get('profile'), token);
} else {
// Use the refresh token we had
auth.refreshIdToken(refreshToken).then(function(idToken) {
store.set('token', idToken);
auth.authenticate(store.get('profile'), token);
});
}
}
}
});
}
})
调用login()函数后会发生这种情况
答案 0 :(得分:0)
您正在致电
cShowProgress.hideProgress();
在示例代码的第12行,但传入函数的参数(第10行)名为
store.set('token', idToken);
。
所以尝试将第12行更改为
token