I am attempting to use Auth0 for my user authentication, but I am having trouble adding it to my Angular project. I'm using Angular1 with Webpack, and it appears that I am not loading Auth0 correctly. This is the contents of my app.js file;
import 'jquery';
import 'bootstrap/dist/css/bootstrap.min.css';
import angular from 'angular';
import uiRouter from 'angular-ui-router';
import auth0 from 'auth0-angular';
import lock from 'auth0-lock';
import cookies from 'angular-cookies';
import storage from 'angular-storage';
import jwt from 'angular-jwt';
import AppComponent from './app.component.js';
import Common from './common/common';
import Components from './components/components';
import './styles.scss';
angular.module('myApp', [
'auth0',
'ui.router',
'angular-storage',
'angular-jwt',
'app.common',
'app.components',
])
.directive('app', AppComponent)
.constant('API', 'http://localhost:8000')
.config(['$urlRouterProvider', 'authProvider', function ($urlRouterProvider, authProvider) {
authProvider.init({
domain: '.eu.auth0.com',
clientID: '',
loginState: 'login'
});
authProvider.on('loginSuccess', function ($location, profilePromise, idToken, store) {
profilePromise.then(function (profile) {
store.set('profile', profile);
store.set('token', idToken);
});
$location.path('/');
});
authProvider.on('loginFailure', function () {
$location.path('/login');
});
$urlRouterProvider.otherwise('/login');
}]).run(['$rootScope', 'auth', 'store', 'jwtHelper', '$urlRouterProvider', function ($rootScope, auth, store, jwtHelper, $urlRouterProvider) {
auth.hookEvents();
}]);
I believe I am importing and loading auth0, so I don't understand why this is happening. I assume it's a minor syntax error..