gpt4 book ai didi

javascript - grunt build 在使用 auth0 时生成错误

转载 作者:行者123 更新时间:2023-11-27 22:59:15 28 4
gpt4 key购买 nike

我在本地使用 angularjs 创建了一个迷你项目,一切正常,控制台中没有错误,但在使用 grunt build 构建项目后,没有任何效果,这是错误:

vendor.ce3c01a3.js:2 Error: [$injector:unpr] Unknown provider: aProvider <-a
http://errors.angularjs.org/1.5.5/$injector/unpr?p0=aProvider%20%3C-%20a
at vendor.ce3c01a3.js:1
at vendor.ce3c01a3.js:1
at Object.d [as get] (vendor.ce3c01a3.js:1)
at vendor.ce3c01a3.js:1
at d (vendor.ce3c01a3.js:1)
at e (vendor.ce3c01a3.js:1)
at Object.g [as invoke] (vendor.ce3c01a3.js:1)
at request (angular-jwt.js:48)
at g (vendor.ce3c01a3.js:3)
at vendor.ce3c01a3.js:3(anonymous function) @ vendor.ce3c01a3.js:2
vendor.ce3c01a3.js:2 Error: [$compile:tpload] Failed to load template: views/customersReport.html (HTTP status: undefined undefined)
http://errors.angularjs.org/1.5.5/$compile/tpload? p0=views%2FcustomersReport.html&p1=undefined&p2=undefined
at vendor.ce3c01a3.js:1
at i (vendor.ce3c01a3.js:3)
at g (vendor.ce3c01a3.js:3)
at vendor.ce3c01a3.js:3
at o.$eval (vendor.ce3c01a3.js:3)
at o.$digest (vendor.ce3c01a3.js:3)
at o.$apply (vendor.ce3c01a3.js:3)
at vendor.ce3c01a3.js:1
at Object.g [as invoke] (vendor.ce3c01a3.js:1)
at g (vendor.ce3c01a3.js:1)(anonymous function) @ vendor.ce3c01a3.js:2

这是我的 app.js 代码:

'use strict';

var app = angular
.module('sampleapp', [
'ngAnimate',
'ngMaterial',
'ngAria',
'ngCookies',
'ngMessages',
'ngResource',
'ngRoute',
'ngSanitize',
'auth0',
'angular-storage',
'angular-jwt'
]);

app.config(function($routeProvider, authProvider, $httpProvider, $locationProvider, jwtInterceptorProvider) {

$routeProvider
.when( '/createAccount', {
controller: 'CreateAccountCtrl',
templateUrl: 'views/admin/createAccount.html',
pageTitle: 'Homepage',
requiresLogin: true
})
.when( '/login', {
controller: 'LoginCtrl',
templateUrl: 'views/admin/login.html',
pageTitle: 'Login'
})
.when( '/users', {
controller: 'UserManagementCtrl',
templateUrl: 'views/admin/usersManagment.html',
pageTitle: 'Account'
})
.when( '/adduser', {
controller: 'AccountCtrl',
templateUrl: 'views/admin/addUser.html',
pageTitle: 'Invite User'
})
.when( '/account', {
controller: 'AccountCtrl',
templateUrl: 'views/admin/account.html',
pageTitle: 'My account'
})
.when( '/', {
controller: 'CustomersReportCtrl',
templateUrl: 'views/customersReport.html',
pageTitle: 'Customers Report'
})
.when( '/customers/:action/:customerId?', {
controller: 'CustomersCtrl',
templateUrl: 'views/addCustomer.html',
pageTitle: '{{action}} Customer'
})

.when( '/loading', {
controller: 'LoadingCtrl',
templateUrl: 'views/loading.html'
})
.when( '/signin', {
controller: 'SigninCtrl',
templateUrl: 'views/signin.html'
})
.when( '/myAccount', {
templateUrl: 'views/myAccount.html',
pageTitle: 'My Account'

})
.otherwise({
redirectTo: '/',
requiresLogin: true
});


authProvider.init({
domain: myDomain,
clientID: myClientID,
loginUrl: '/login'
});

authProvider.on('loginSuccess', function($location, profilePromise, idToken, store, datastoreUser) {

console.log("Login Success");

profilePromise.then(function(profile) {
store.set('profile', profile);
store.set('token', idToken);

datastoreUser.getUserIdentity(profile.email).then(function(result) {
console.log(result)
if (result.data.status == "FOUND") {
$location.path("/");
}else{
$location.path("/createAccount");

}
});

});

$location.path("/loading");
});

authProvider.on('loginFailure', function() {
alert("Error");
});

jwtInterceptorProvider.tokenGetter = function(store) {
return store.get('token');
};
$httpProvider.interceptors.push('jwtInterceptor');
});


app.config(function($mdThemingProvider) {$mdThemingProvider.theme('default')
.primaryPalette('cyan', {
'default': '800',
'hue-1': '50',
'hue-2': '500',
'hue-3': '900'
})
// If you specify less than all of the keys, it will inherit from the
// default shades
.accentPalette('grey', {
'default': '50',
'hue-1' : '200'
});
});


app.run(function($rootScope,$timeout, auth, store, jwtHelper, $location, datastoreDomain, userSession, datastoreUser, $q) {

$rootScope.$on('$locationChangeStart', function() {

var token = store.get('token');
if (token) {
if (!jwtHelper.isTokenExpired(token)) {
if (!auth.isAuthenticated) {
auth.authenticate(store.get('profile'), token);
getUserIdentity()
}
} else {
// Either show the login page or use the refresh token to get a new idToken
$location.path('/login');
}
}

});

function getUserIdentity(){

datastoreUser.getUserIdentity(auth.profile.email).then(function(result) {
console.log(result)
if (result.data.status == "FOUND") {
console.log(auth)
var domainPromise = datastoreDomain.getById(result.data.identity.domainId).then(function(result){
console.log(result.data)
userSession.setDomain(result.data);
});

console.log(auth.profile.email)
var userPromise = datastoreUser.getById(auth.profile.email).then(function(result){

console.log(result);
userSession.setUser(result.data.user);

$rootScope.userIdentity = {
displayName: result.data.user.displayName,
email: result.data.user.email,
domainName: result.data.user.domain.name,
domainPlan: result.data.user.domain.plan,
userRole: result.data.user.role,
imageUrl: result.data.user.imageUrl
}

});

$q.all([domainPromise, userPromise]).then(function(){
$location.path("/");
})

}else{
$location.path("/createAccount");

}
});
}


});

我已经尝试了一切,但没有成功

最佳答案

我找到了解决我的问题的方法,它非常简单,如果其他人遇到同样的问题,请使用此修复程序来解决未知的未知提供程序:缩小后的 aProvider。

jwtInterceptorProvider.tokenGetter = ['store', function (store) {
return store.get('token');
}];

关于javascript - grunt build 在使用 auth0 时生成错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37274553/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com