auth0-samples / auth0-angularjs-sample

These samples are made up of steps to add Auth0 to an Angular JS app
28 stars 111 forks source link

RequireJs example with auth0 #50

Open ganeshkaspate opened 6 years ago

ganeshkaspate commented 6 years ago

Hey, I am using auth0 for my angularJs application. Actually I am getting this error

This is my config.js **require.config({

waitSeconds: 60,

paths: {
    angular: '../bower_components/angular/angular',
    'angular-ui-router': '../bower_components/angular-ui-router/release/angular-ui-router',
    jquery: '../bower_components/jquery/dist/jquery.min',
    jqueryui: '../bower_components/jquery-ui/jquery-ui.min',
    bootstrap: '../bower_components/bootstrap/dist/js/bootstrap.min',
    underscore: '../bower_components/underscore/underscore-min',
    'angular-ui-utils': '../bower_components/angular-ui-utils/ui-utils.min',
    'moment': '../bower_components/moment/moment',
    'cookies': '../bower_components/cookies-js/dist/cookies',
    'angular-bootstrap': '../bower_components/angular-bootstrap/ui-bootstrap-tpls',
    'toastr': '../bower_components/angular-toastr/dist/angular-toastr.tpls',
    'angularTreeview': '../libs/angular.treeview/angular.treeview',
    'angular-confirm-modal': '../bower_components/angular-confirm-modal/angular-confirm.min',
    'rangy-core': '../bower_components/rangy/rangy-core.min',
    'rangy-selectionsave': '../bower_components/rangy/rangy-selectionsaverestore.min',
    'textAngular-sanitize': '../libs/textAngular/textAngular-sanitize.min',
    'textAngularSetup': '../libs/textAngular/textAngularSetup',
    'textAngular': '../libs/textAngular/textAngular',
    'anguFixedHeaderTable': '../bower_components/angu-fixed-header-table/angu-fixed-header-table',
    'io.dennis.contextmenu': '../bower_components/angular-contextmenu/dist/contextmenu',
    'bootstrap-tokenfield': '../bower_components/bootstrap-tokenfield/dist/bootstrap-tokenfield.min',
    'auth0': "../bower_components/auth0.js/build/auth0",
    'auth0.auth0': "../bower_components/angular-auth0/dist/angular-auth0"
},

shim: {
    jquery: {
        exports: 'jquery'
    },
    jqueryui: {
        deps: ['jquery']
    },
    bootstrap: {
        deps: ['jquery']
    },
    angular: {
        exports: 'angular',
        deps: ['jquery']
    },
    'angular-ui-router': {
        deps: ['angular']
    },
    'angular-ui-utils': {
        deps: ['angular']
    },
    'angular-bootstrap': {
        deps: ['angular']
    },
    'toastr': {
        deps: ['angular']
    },
    'angularTreeview': {
        deps: ['angular']
    },
    'angular-confirm-modal': {
        deps: ['angular', 'angular-bootstrap']
    },
    'textAngularRangySetup': {
        exports: 'rangy'
    },
    'rangy-selectionsave': {
        deps: ['rangy-core']
    },
    'textAngular-sanitize': {
        deps: ['angular']
    },
    'textAngularSetup': {
        deps: ['angular']
    },
    'textAngular': {
        exports: 'textAngular',
        deps: ['angular', 'textAngular-sanitize', 'textAngularSetup']
    },
    'anguFixedHeaderTable': {
        deps: ['angular']
    },
    'io.dennis.contextmenu': {
        deps: ['angular']
    },
    'bootstrap-tokenfield': {
        deps: ['jquery']
    },
    'auth0': {
        exports: "auth0"
    },
    'auth0.auth0': {
        "deps": ["angular", "auth0"]
    },
}

});

require(['rangy-core', 'rangy-selectionsave'], function (rangyCore) { window.rangy = rangyCore; });**

App.js

define([ 'angular', 'angular-ui-router', 'auth0', 'auth0.auth0' ], function(angular, appConfig, suggestions, displayMapping, AppConstants) { 'use strict';

**// define the module and any module dependencies
var appModule = angular.module('app', [
    'ui.router',
    'ui.bootstrap',
    'toastr',
    'angularTreeview',
    'angular-confirm',
    'textAngular',
    'anguFixedHeaderTable',
    'io.dennis.contextmenu'    
    ]);

//configure module
appModule
    .config(appConfig);

return appModule;

});**

My main.js

**[define([ 'jquery', 'underscore', 'angular', 'bootstrap', 'jqueryui', 'app/app' ], function($, _, angular) { 'use strict';

try {
    if (!window.jasmine) {
        angular.bootstrap(document, ['app']);
    }
} catch (e) {
    // don't bootstrap more than once.
    if(this.console && this.console.log){
      console.log(e);
    }
}

});](url)**

so, Here I am getting this error.

Uncaught ReferenceError: auth0 is not defined at Object. (angular-auth0.js:152) at webpack_require (angular-auth0.js:20) at Object.module.exports (angular-auth0.js:74) at webpack_require (angular-auth0.js:20) at Object.defineProperty.value (angular-auth0.js:63) at angular-auth0.js:66

So, How to resolve this issue ?

Ecarbone70 commented 6 years ago

@ganeshkaspate i think you could follow my example, i wrote a simple file preauth.js that i call in deps, so no needs to call auth0 module in main. look at that, i'm not so skilled to help you more than this.