angular - Issues Importing Auth0 into Angular2/.NETCore Project -


i trying implement custom login auth0 service having troubles imports. trouble declare var auth0: any. whenever try get:

exception: uncaught (in promise): referenceerror: auth0 not defined

the thing is, tried login example using declare var auth0lock: any , worked. using .net core+angular2 solution compiles webpack. not sure if have add webpack.config.js here is:

// configuration in common both client-side , server-side bundles var sharedconfig = { resolve: { extensions: [ '', '.js', '.ts', '.scss' ] }, output: {     filename: '[name].js',     publicpath: '/dist/' // webpack dev middleware, if enabled, handles requests url prefix }, module: {     loaders: [         { test: /\.ts$/, include: /clientapp/, loader: 'ts', query: { silent: true } },         { test: /\.ts$/, include: /clientapp/, loader: 'angular2-router-loader' },         { test: /\.html$/, loader: 'raw' },         { test: /\.css$/, loader: 'to-string!css' },         { test: /\.(png|jpg|jpeg|gif|svg)$/, loader: 'url', query: { limit: 25000 } },         { test: /\.scss$/, exclude: /node_modules/, loaders: ["raw-loader", "sass-loader"] },         { test: /jquery\.flot\.resize\.js$/, loader: "imports?this=>window" }     ] } };  // configuration client-side bundle suitable running in browsers var clientbundleconfig = merge(sharedconfig, { entry: {     'main-client': './clientapp/boot-client.ts' }, output: { path: path.join(__dirname, './wwwroot/dist') }, devtool: isdevbuild ? 'inline-source-map' : null, plugins: [     new webpack.dllreferenceplugin({         context: __dirname,         manifest: require('./wwwroot/dist/vendor-manifest.json')     }) ].concat(isdevbuild ? [] : [     // plugins apply in production builds     new webpack.optimize.occurenceorderplugin(),     new webpack.optimize.uglifyjsplugin() ]) });  // configuration server-side (prerendering) bundle suitable running in node var serverbundleconfig = merge(sharedconfig, { entry: { 'main-server': './clientapp/boot-server.ts' }, output: {     librarytarget: 'commonjs',     path: path.join(__dirname, './clientapp/dist') }, target: 'node', devtool: 'inline-source-map', externals: [nodeexternals({ whitelist: [allfilenamesexceptjavascript] })] //  don't bundle .js files node_modules });  //var authbundleconfig = merge(sharedconfig, { //    entry: "../../node_modules/auth0-js/src/index.js", //    output: { //        filename: filename.join(__dirname, 'build.js') //    }, //    module: { //        loaders: [{ //            test: /\.js$/, //            exclude: /(node_modules|bower_components)/, //            loader: 'babel' //        }] //    } //});  module.exports = [clientbundleconfig, serverbundleconfig/*, authbundleconfig*/]; 

as can see tried add authbundle didn't work.

my service:

// app/core/authentication/auth.service.ts  import { injectable } '@angular/core'; import { router } '@angular/router'; import { tokennotexpired } 'angular2-jwt';  import { myconfig } './auth.config';  const auth0 = require('auth0-js').default; //declare var auth0: any;  @injectable() export class authservice { // configure auth0 private auth0 = new auth0.webauth({     domain: myconfig.domain,     clientid: myconfig.clientid,     redirecturi: myconfig.callbackurl,     responsetype: 'token id_token' });  constructor(private router: router) { } ... 

any appreciated.

i got import work installing latest auth0-js typings via npm , using import * auth0 'auth0-js'; in auth.service.


Comments

Popular posts from this blog

Command prompt result in label. Python 2.7 -

javascript - How do I use URL parameters to change link href on page? -

amazon web services - AWS Route53 Trying To Get Site To Resolve To www -