auth0-angular
Advanced tools
Comparing version 4.0.0 to 4.0.2
/** | ||
* Angular SDK to use with Auth0 | ||
* @version v3.0.6 - 2014-12-19 | ||
* @version v4.0.1 - 2015-04-20 | ||
* @link https://auth0.com | ||
@@ -152,2 +152,27 @@ * @author Martin Gontovnikas | ||
} | ||
function constructorName(fun) { | ||
if (fun) { | ||
return { | ||
lib: authUtilsProvider.fnName(fun), | ||
constructor: fun | ||
}; | ||
} | ||
/* jshint ignore:start */ | ||
if (null != window.Auth0Lock) { | ||
return { | ||
lib: 'Auth0Lock', | ||
constructor: window.Auth0Lock | ||
}; | ||
} | ||
if (null != window.Auth0) { | ||
return { | ||
lib: 'Auth0', | ||
constructor: window.Auth0 | ||
}; | ||
} | ||
if (null != Auth0Widget) { | ||
throw new Error('Auth0Widget is not supported with this version of auth0-angular' + 'anymore. Please try with an older one'); | ||
} | ||
throw new Error('Cannott initialize Auth0Angular. Auth0Lock or Auth0 must be available'); /* jshint ignore:end */ | ||
} | ||
this.init = function (options, Auth0Constructor) { | ||
@@ -162,22 +187,12 @@ if (!options) { | ||
this.sso = options.sso; | ||
var Constructor = Auth0Constructor; | ||
if (!Constructor && typeof Auth0Lock !== 'undefined') { | ||
Constructor = Auth0Lock; | ||
} | ||
if (!Constructor && typeof Auth0 !== 'undefined') { | ||
Constructor = Auth0; | ||
} | ||
if (authUtilsProvider.fnName(Constructor) === 'Auth0Widget') { | ||
throw new Error('Auth0Widget is not supported with this ' + ' version of auth0-angular anymore. Please try with an older one'); | ||
} | ||
if (authUtilsProvider.fnName(Constructor) === 'Auth0Lock') { | ||
this.auth0lib = new Constructor(this.clientID, domain, angular.extend(defaultOptions, options)); | ||
var constructorInfo = constructorName(Auth0Constructor); | ||
this.lib = constructorInfo.lib; | ||
if (constructorInfo.lib === 'Auth0Lock') { | ||
this.auth0lib = new constructorInfo.constructor(this.clientID, domain, angular.extend(defaultOptions, options)); | ||
this.auth0js = this.auth0lib.getClient(); | ||
this.isLock = true; | ||
this.lib = 'Auth0Lock'; | ||
} else { | ||
this.auth0lib = new Constructor(angular.extend(defaultOptions, options)); | ||
this.auth0lib = new constructorInfo.constructor(angular.extend(defaultOptions, options)); | ||
this.auth0js = this.auth0lib; | ||
this.isLock = false; | ||
this.lib = 'Auth0'; | ||
} | ||
@@ -263,2 +278,3 @@ this.initialized = true; | ||
popup: false, | ||
callbackOnLocationHash: true, | ||
connection: ssoData.lastUsedConnection.name | ||
@@ -265,0 +281,0 @@ }, null, null, 'Auth0'); |
@@ -1,1 +0,1 @@ | ||
!function(){angular.module("auth0",["auth0.service","auth0.utils"]).run(["auth",function(a){a.hookEvents()}]),angular.module("auth0.utils",[]).provider("authUtils",function(){var a={capitalize:function(a){return a?a.charAt(0).toUpperCase()+a.substring(1).toLowerCase():null},fnName:function(a){var b=a.toString();return b=b.substr("function ".length),b=b.substr(0,b.indexOf("(")),b?b.trim():b}};angular.extend(this,a),this.$get=["$rootScope","$q",function(b,c){var d={};return angular.extend(d,a),d.safeApply=function(a){var c=b.$root.$$phase;"$apply"===c||"$digest"===c?a&&"function"==typeof a&&a():b.$apply(a)},d.callbackify=function(a,b,c,e){return angular.isFunction(a)?function(f){f=Array.prototype.slice.call(arguments);var g=function(a,d,e){return a?void(c&&c(a)):(e=Array.prototype.slice.call(arguments,1),void(b&&b.apply(null,e)))};(b||c)&&f.push(d.applied(g)),a.apply(e,f)}:void 0},d.promisify=function(a,b){return angular.isFunction(a)?function(e){e=Array.prototype.slice.call(arguments);var f=c.defer(),g=function(a,b,c){return a?void f.reject(a):(c=Array.prototype.slice.call(arguments,1),void f.resolve(c.length>1?c:b))};return e.push(d.applied(g)),a.apply(b,e),f.promise.spread=f.promise.spread||function(a,b){return f.promise.then(function(b){return Array.isArray(b)?a.apply(null,b):a(b)},b)},f.promise}:void 0},d.applied=function(a){return function(b,c){b=b,c=c;var e=arguments;d.safeApply(function(){a.apply(null,e)})}},d}]}),angular.module("auth0.service",["auth0.utils"]).provider("auth",["authUtilsProvider",function(a){function b(a,b){b=b||e.lib;var c=f[b].library();return c[f[b][a]]}function c(a,b){return b=b||e.lib,f[b][a]}var d={callbackOnLocationHash:!0},e=this,f={Auth0:{signin:"login",signup:"signup",reset:"changePassword",library:function(){return e.auth0js},parseOptions:function(a){var b=angular.copy(a);return b.authParams&&(angular.extend(b,b.authParams),delete b.authParams),b}},Auth0Lock:{signin:"show",signup:"showSignup",reset:"showReset",library:function(){return e.auth0lib},parseOptions:function(a){return angular.copy(a)}}};this.init=function(b,c){if(!b)throw new Error("You must set options when calling init");this.loginUrl=b.loginUrl,this.loginState=b.loginState,this.clientID=b.clientID||b.clientId;var e=b.domain;this.sso=b.sso;var f=c;if(f||"undefined"==typeof Auth0Lock||(f=Auth0Lock),f||"undefined"==typeof Auth0||(f=Auth0),"Auth0Widget"===a.fnName(f))throw new Error("Auth0Widget is not supported with this version of auth0-angular anymore. Please try with an older one");"Auth0Lock"===a.fnName(f)?(this.auth0lib=new f(this.clientID,e,angular.extend(d,b)),this.auth0js=this.auth0lib.getClient(),this.isLock=!0,this.lib="Auth0Lock"):(this.auth0lib=new f(angular.extend(d,b)),this.auth0js=this.auth0lib,this.isLock=!1,this.lib="Auth0"),this.initialized=!0},this.eventHandlers={},this.on=function(a,b){this.eventHandlers[a]||(this.eventHandlers[a]=[]),this.eventHandlers[a].push(b)};var g=["loginSuccess","loginFailure","logout","forbidden","authenticated"];angular.forEach(g,function(b){e["add"+a.capitalize(b)+"Handler"]=function(a){e.on(b,a)}}),this.$get=["$rootScope","$q","$injector","$window","$location","authUtils",function(a,d,g,h,i,j){function k(){e.loginUrl?i.path(e.loginUrl):e.loginState?g.get("$state").go(e.loginState):n("forbidden")}var l={isAuthenticated:!1},m=function(a){return e.eventHandlers[a]},n=function(b,c){a.$broadcast("auth0."+b,c),angular.forEach(m(b)||[],function(a){g.invoke(a,l,c)})},o=function(a,b,c,d,e,f){var g=l.getProfile(a),h={idToken:a,accessToken:b,state:c,refreshToken:d,profile:e,isAuthenticated:!0};return angular.extend(l,h),n(f?"authenticated":"loginSuccess",angular.extend({profilePromise:g},h)),g};a.$on("$locationChangeStart",function(){if(e.initialized){var a=e.auth0lib.parseHash(h.location.hash);if(!l.isAuthenticated){if(a&&a.id_token)return void o(a.id_token,a.access_token,a.state,a.refresh_token);e.sso&&e.auth0js.getSSOData(j.applied(function(a,b){b.sso&&l.signin({popup:!1,connection:b.lastUsedConnection.name},null,null,"Auth0")}))}}}),a.$on("auth0.forbiddenRequest",function(){k()}),e.loginUrl&&a.$on("$routeChangeStart",function(a,b){e.initialized&&b.$$route&&b.$$route.requiresLogin&&(l.isAuthenticated||l.refreshTokenPromise||i.path(e.loginUrl))}),e.loginState&&a.$on("$stateChangeStart",function(a,b){e.initialized&&b.data&&b.data.requiresLogin&&(l.isAuthenticated||l.refreshTokenPromise||(a.preventDefault(),g.get("$state").go(e.loginState)))}),l.config=e;var p=function(a,b){var c=m("loginSuccess");if(!(b||a.username||a.email||c&&0!==c.length))throw new Error("You must define a loginSuccess handler if not using popup mode or not doing ro call because that means you are doing a redirect")};return l.hookEvents=function(){},l.init=angular.bind(e,e.init),l.getToken=function(a){a=a||{scope:"openid"},a.id_token||a.refresh_token||(a.id_token=l.idToken);var b=j.promisify(e.auth0js.getDelegationToken,e.auth0js);return b(a)},l.refreshIdToken=function(a){var b=j.promisify(e.auth0js.refreshToken,e.auth0js);return l.refreshTokenPromise=b(a||l.refreshToken).then(function(a){return a.id_token})["finally"](function(){l.refreshTokenPromise=null}),l.refreshTokenPromise},l.renewIdToken=function(a){var b=j.promisify(e.auth0js.renewIdToken,e.auth0js);return b(a||l.idToken).then(function(a){return a.id_token})},l.signin=function(a,d,g,h){a=a||{},p(a,d,g),a=c("parseOptions",h)(a);var i=b("signin",h),k=d?function(a,b,c,e,f){o(b,c,e,f,a).then(function(a){d&&d(a,b,c,e,f)})}:null,l=g?function(a){n("loginFailure",{error:a}),g&&g(a)}:null,m=j.callbackify(i,k,l,f[h||e.lib].library());m(a)},l.signup=function(a,d,f){a=a||{},p(a,d,f),a=c("parseOptions")(a);var g=d?function(b,c,e,f,g){angular.isUndefined(a.auto_login)||a.auto_login?o(c,e,f,g,b).then(function(a){d&&d(a,c,e,f,g)}):d()}:null,h=f?function(a){n("loginFailure",{error:a}),f&&f(a)}:null,i=e.auth0lib,k=j.callbackify(b("signup"),g,h,i);k(a)},l.reset=function(a,d,f){a=a||{},a=c("parseOptions")(a);var g=e.auth0lib,h=j.callbackify(b("reset"),d,f,g);h(a)},l.signout=function(){l.isAuthenticated=!1,l.profile=null,l.profilePromise=null,l.idToken=null,l.state=null,l.accessToken=null,l.tokenPayload=null,n("logout")},l.authenticate=function(a,b,c,d,e){return o(b,c,d,e,a,!0)},l.getProfile=function(a){var b=j.promisify(e.auth0lib.getProfile,e.auth0lib);return l.profilePromise=b(a||l.idToken),l.profilePromise.then(function(a){return l.profile=a,a})},l}]}])}(); | ||
!function(){angular.module("auth0",["auth0.service","auth0.utils"]).run(["auth",function(a){a.hookEvents()}]),angular.module("auth0.utils",[]).provider("authUtils",function(){var a={capitalize:function(a){return a?a.charAt(0).toUpperCase()+a.substring(1).toLowerCase():null},fnName:function(a){var b=a.toString();return b=b.substr("function ".length),b=b.substr(0,b.indexOf("(")),b?b.trim():b}};angular.extend(this,a),this.$get=["$rootScope","$q",function(b,c){var d={};return angular.extend(d,a),d.safeApply=function(a){var c=b.$root.$$phase;"$apply"===c||"$digest"===c?a&&"function"==typeof a&&a():b.$apply(a)},d.callbackify=function(a,b,c,e){return angular.isFunction(a)?function(f){f=Array.prototype.slice.call(arguments);var g=function(a,d,e){return a?void(c&&c(a)):(e=Array.prototype.slice.call(arguments,1),void(b&&b.apply(null,e)))};(b||c)&&f.push(d.applied(g)),a.apply(e,f)}:void 0},d.promisify=function(a,b){return angular.isFunction(a)?function(e){e=Array.prototype.slice.call(arguments);var f=c.defer(),g=function(a,b,c){return a?void f.reject(a):(c=Array.prototype.slice.call(arguments,1),void f.resolve(c.length>1?c:b))};return e.push(d.applied(g)),a.apply(b,e),f.promise.spread=f.promise.spread||function(a,b){return f.promise.then(function(b){return Array.isArray(b)?a.apply(null,b):a(b)},b)},f.promise}:void 0},d.applied=function(a){return function(b,c){b=b,c=c;var e=arguments;d.safeApply(function(){a.apply(null,e)})}},d}]}),angular.module("auth0.service",["auth0.utils"]).provider("auth",["authUtilsProvider",function(a){function b(a,b){b=b||f.lib;var c=g[b].library();return c[g[b][a]]}function c(a,b){return b=b||f.lib,g[b][a]}function d(b){if(b)return{lib:a.fnName(b),constructor:b};if(null!=window.Auth0Lock)return{lib:"Auth0Lock",constructor:window.Auth0Lock};if(null!=window.Auth0)return{lib:"Auth0",constructor:window.Auth0};if(null!=Auth0Widget)throw new Error("Auth0Widget is not supported with this version of auth0-angularanymore. Please try with an older one");throw new Error("Cannott initialize Auth0Angular. Auth0Lock or Auth0 must be available")}var e={callbackOnLocationHash:!0},f=this,g={Auth0:{signin:"login",signup:"signup",reset:"changePassword",library:function(){return f.auth0js},parseOptions:function(a){var b=angular.copy(a);return b.authParams&&(angular.extend(b,b.authParams),delete b.authParams),b}},Auth0Lock:{signin:"show",signup:"showSignup",reset:"showReset",library:function(){return f.auth0lib},parseOptions:function(a){return angular.copy(a)}}};this.init=function(a,b){if(!a)throw new Error("You must set options when calling init");this.loginUrl=a.loginUrl,this.loginState=a.loginState,this.clientID=a.clientID||a.clientId;var c=a.domain;this.sso=a.sso;var f=d(b);this.lib=f.lib,"Auth0Lock"===f.lib?(this.auth0lib=new f.constructor(this.clientID,c,angular.extend(e,a)),this.auth0js=this.auth0lib.getClient(),this.isLock=!0):(this.auth0lib=new f.constructor(angular.extend(e,a)),this.auth0js=this.auth0lib,this.isLock=!1),this.initialized=!0},this.eventHandlers={},this.on=function(a,b){this.eventHandlers[a]||(this.eventHandlers[a]=[]),this.eventHandlers[a].push(b)};var h=["loginSuccess","loginFailure","logout","forbidden","authenticated"];angular.forEach(h,function(b){f["add"+a.capitalize(b)+"Handler"]=function(a){f.on(b,a)}}),this.$get=["$rootScope","$q","$injector","$window","$location","authUtils",function(a,d,e,h,i,j){function k(){f.loginUrl?i.path(f.loginUrl):f.loginState?e.get("$state").go(f.loginState):n("forbidden")}var l={isAuthenticated:!1},m=function(a){return f.eventHandlers[a]},n=function(b,c){a.$broadcast("auth0."+b,c),angular.forEach(m(b)||[],function(a){e.invoke(a,l,c)})},o=function(a,b,c,d,e,f){var g=l.getProfile(a),h={idToken:a,accessToken:b,state:c,refreshToken:d,profile:e,isAuthenticated:!0};return angular.extend(l,h),n(f?"authenticated":"loginSuccess",angular.extend({profilePromise:g},h)),g};a.$on("$locationChangeStart",function(){if(f.initialized){var a=f.auth0lib.parseHash(h.location.hash);if(!l.isAuthenticated){if(a&&a.id_token)return void o(a.id_token,a.access_token,a.state,a.refresh_token);f.sso&&f.auth0js.getSSOData(j.applied(function(a,b){b.sso&&l.signin({popup:!1,callbackOnLocationHash:!0,connection:b.lastUsedConnection.name},null,null,"Auth0")}))}}}),a.$on("auth0.forbiddenRequest",function(){k()}),f.loginUrl&&a.$on("$routeChangeStart",function(a,b){f.initialized&&b.$$route&&b.$$route.requiresLogin&&(l.isAuthenticated||l.refreshTokenPromise||i.path(f.loginUrl))}),f.loginState&&a.$on("$stateChangeStart",function(a,b){f.initialized&&b.data&&b.data.requiresLogin&&(l.isAuthenticated||l.refreshTokenPromise||(a.preventDefault(),e.get("$state").go(f.loginState)))}),l.config=f;var p=function(a,b){var c=m("loginSuccess");if(!(b||a.username||a.email||c&&0!==c.length))throw new Error("You must define a loginSuccess handler if not using popup mode or not doing ro call because that means you are doing a redirect")};return l.hookEvents=function(){},l.init=angular.bind(f,f.init),l.getToken=function(a){a=a||{scope:"openid"},a.id_token||a.refresh_token||(a.id_token=l.idToken);var b=j.promisify(f.auth0js.getDelegationToken,f.auth0js);return b(a)},l.refreshIdToken=function(a){var b=j.promisify(f.auth0js.refreshToken,f.auth0js);return l.refreshTokenPromise=b(a||l.refreshToken).then(function(a){return a.id_token})["finally"](function(){l.refreshTokenPromise=null}),l.refreshTokenPromise},l.renewIdToken=function(a){var b=j.promisify(f.auth0js.renewIdToken,f.auth0js);return b(a||l.idToken).then(function(a){return a.id_token})},l.signin=function(a,d,e,h){a=a||{},p(a,d,e),a=c("parseOptions",h)(a);var i=b("signin",h),k=d?function(a,b,c,e,f){o(b,c,e,f,a).then(function(a){d&&d(a,b,c,e,f)})}:null,l=e?function(a){n("loginFailure",{error:a}),e&&e(a)}:null,m=j.callbackify(i,k,l,g[h||f.lib].library());m(a)},l.signup=function(a,d,e){a=a||{},p(a,d,e),a=c("parseOptions")(a);var g=d?function(b,c,e,f,g){angular.isUndefined(a.auto_login)||a.auto_login?o(c,e,f,g,b).then(function(a){d&&d(a,c,e,f,g)}):d()}:null,h=e?function(a){n("loginFailure",{error:a}),e&&e(a)}:null,i=f.auth0lib,k=j.callbackify(b("signup"),g,h,i);k(a)},l.reset=function(a,d,e){a=a||{},a=c("parseOptions")(a);var g=f.auth0lib,h=j.callbackify(b("reset"),d,e,g);h(a)},l.signout=function(){l.isAuthenticated=!1,l.profile=null,l.profilePromise=null,l.idToken=null,l.state=null,l.accessToken=null,l.tokenPayload=null,n("logout")},l.authenticate=function(a,b,c,d,e){return o(b,c,d,e,a,!0)},l.getProfile=function(a){var b=j.promisify(f.auth0lib.getProfile,f.auth0lib);return l.profilePromise=b(a||l.idToken),l.profilePromise.then(function(a){return l.profile=a,a})},l}]}])}(); |
# 4.0.X | ||
# 4.0.0 | ||
## 4.0.2 | ||
* Fixed bug with SSO | ||
## 4.0.1 | ||
* Fixed minification problem with `auth0-angular` and `Lock` | ||
## 4.0.0 | ||
* `getToken` method now returns the full delegation object instead of just the `id_token`. This **breaks backward compatibility** with the previous version. It lets you use `auth0-angular` for other delegations besides Auth0 like Amazon which doesn't return an `id_token` | ||
@@ -6,0 +12,0 @@ * Post install script has been removed. It forced people using this library to have `bower` installed. |
@@ -34,9 +34,21 @@ # Refresh tokens | ||
.config(function($httpProvider, jwtInterceptorProvider) { | ||
var refreshingToken = null; | ||
jwtInterceptorProvider.tokenGetter = function(store, $http, jwtHelper) { | ||
var idToken = store.get('token'); | ||
var token = store.get('token'); | ||
var refreshToken = store.get('refreshToken'); | ||
if (jwtHelper.isTokenExpired(idToken)) { | ||
return auth.refreshIdToken(refreshToken); | ||
} else { | ||
return idToken; | ||
if (token) { | ||
if (!jwtHelper.isTokenExpired(token)) { | ||
return store.get('token'); | ||
} else { | ||
if (refreshingToken === null) { | ||
refreshingToken = auth.refreshIdToken(refreshToken).then(function(idToken) { | ||
store.set('token', idToken); | ||
return idToken; | ||
}).finally(function() { | ||
refreshingToken = null; | ||
}); | ||
} | ||
return refreshingToken; | ||
} | ||
} | ||
@@ -56,2 +68,3 @@ } | ||
.run(function($rootScope, auth, store, jwtHelper, $location) { | ||
var refreshingToken = null; | ||
$rootScope.$on('$locationChangeStart', function() { | ||
@@ -66,6 +79,11 @@ if (!auth.isAuthenticated) { | ||
if (refreshToken) { | ||
return auth.refreshIdToken(refreshToken).then(function(idToken) { | ||
store.set('token', idToken); | ||
auth.authenticate(store.get('profile'), idToken); | ||
}); | ||
if (refreshingToken === null) { | ||
refreshingToken = auth.refreshIdToken(refreshToken).then(function(idToken) { | ||
store.set('token', idToken); | ||
auth.authenticate(store.get('profile'), idToken); | ||
}).finally(function() { | ||
refreshingToken = null; | ||
}); | ||
} | ||
return refreshingToken; | ||
} else { | ||
@@ -72,0 +90,0 @@ $location.path('/login'); |
/** | ||
* Angular SDK to use with Auth0 | ||
* @version v3.0.6 - 2014-12-19 | ||
* @version v4.0.1 - 2015-04-20 | ||
* @link https://auth0.com | ||
@@ -152,2 +152,27 @@ * @author Martin Gontovnikas | ||
} | ||
function constructorName(fun) { | ||
if (fun) { | ||
return { | ||
lib: authUtilsProvider.fnName(fun), | ||
constructor: fun | ||
}; | ||
} | ||
/* jshint ignore:start */ | ||
if (null != window.Auth0Lock) { | ||
return { | ||
lib: 'Auth0Lock', | ||
constructor: window.Auth0Lock | ||
}; | ||
} | ||
if (null != window.Auth0) { | ||
return { | ||
lib: 'Auth0', | ||
constructor: window.Auth0 | ||
}; | ||
} | ||
if (null != Auth0Widget) { | ||
throw new Error('Auth0Widget is not supported with this version of auth0-angular' + 'anymore. Please try with an older one'); | ||
} | ||
throw new Error('Cannott initialize Auth0Angular. Auth0Lock or Auth0 must be available'); /* jshint ignore:end */ | ||
} | ||
this.init = function (options, Auth0Constructor) { | ||
@@ -162,22 +187,12 @@ if (!options) { | ||
this.sso = options.sso; | ||
var Constructor = Auth0Constructor; | ||
if (!Constructor && typeof Auth0Lock !== 'undefined') { | ||
Constructor = Auth0Lock; | ||
} | ||
if (!Constructor && typeof Auth0 !== 'undefined') { | ||
Constructor = Auth0; | ||
} | ||
if (authUtilsProvider.fnName(Constructor) === 'Auth0Widget') { | ||
throw new Error('Auth0Widget is not supported with this ' + ' version of auth0-angular anymore. Please try with an older one'); | ||
} | ||
if (authUtilsProvider.fnName(Constructor) === 'Auth0Lock') { | ||
this.auth0lib = new Constructor(this.clientID, domain, angular.extend(defaultOptions, options)); | ||
var constructorInfo = constructorName(Auth0Constructor); | ||
this.lib = constructorInfo.lib; | ||
if (constructorInfo.lib === 'Auth0Lock') { | ||
this.auth0lib = new constructorInfo.constructor(this.clientID, domain, angular.extend(defaultOptions, options)); | ||
this.auth0js = this.auth0lib.getClient(); | ||
this.isLock = true; | ||
this.lib = 'Auth0Lock'; | ||
} else { | ||
this.auth0lib = new Constructor(angular.extend(defaultOptions, options)); | ||
this.auth0lib = new constructorInfo.constructor(angular.extend(defaultOptions, options)); | ||
this.auth0js = this.auth0lib; | ||
this.isLock = false; | ||
this.lib = 'Auth0'; | ||
} | ||
@@ -263,2 +278,3 @@ this.initialized = true; | ||
popup: false, | ||
callbackOnLocationHash: true, | ||
connection: ssoData.lastUsedConnection.name | ||
@@ -265,0 +281,0 @@ }, null, null, 'Auth0'); |
/** | ||
* Angular SDK to use with Auth0 | ||
* @version v3.0.6 - 2014-12-19 | ||
* @version v4.0.1 - 2015-04-20 | ||
* @link https://auth0.com | ||
@@ -152,2 +152,27 @@ * @author Martin Gontovnikas | ||
} | ||
function constructorName(fun) { | ||
if (fun) { | ||
return { | ||
lib: authUtilsProvider.fnName(fun), | ||
constructor: fun | ||
}; | ||
} | ||
/* jshint ignore:start */ | ||
if (null != window.Auth0Lock) { | ||
return { | ||
lib: 'Auth0Lock', | ||
constructor: window.Auth0Lock | ||
}; | ||
} | ||
if (null != window.Auth0) { | ||
return { | ||
lib: 'Auth0', | ||
constructor: window.Auth0 | ||
}; | ||
} | ||
if (null != Auth0Widget) { | ||
throw new Error('Auth0Widget is not supported with this version of auth0-angular' + 'anymore. Please try with an older one'); | ||
} | ||
throw new Error('Cannott initialize Auth0Angular. Auth0Lock or Auth0 must be available'); /* jshint ignore:end */ | ||
} | ||
this.init = function (options, Auth0Constructor) { | ||
@@ -162,22 +187,12 @@ if (!options) { | ||
this.sso = options.sso; | ||
var Constructor = Auth0Constructor; | ||
if (!Constructor && typeof Auth0Lock !== 'undefined') { | ||
Constructor = Auth0Lock; | ||
} | ||
if (!Constructor && typeof Auth0 !== 'undefined') { | ||
Constructor = Auth0; | ||
} | ||
if (authUtilsProvider.fnName(Constructor) === 'Auth0Widget') { | ||
throw new Error('Auth0Widget is not supported with this ' + ' version of auth0-angular anymore. Please try with an older one'); | ||
} | ||
if (authUtilsProvider.fnName(Constructor) === 'Auth0Lock') { | ||
this.auth0lib = new Constructor(this.clientID, domain, angular.extend(defaultOptions, options)); | ||
var constructorInfo = constructorName(Auth0Constructor); | ||
this.lib = constructorInfo.lib; | ||
if (constructorInfo.lib === 'Auth0Lock') { | ||
this.auth0lib = new constructorInfo.constructor(this.clientID, domain, angular.extend(defaultOptions, options)); | ||
this.auth0js = this.auth0lib.getClient(); | ||
this.isLock = true; | ||
this.lib = 'Auth0Lock'; | ||
} else { | ||
this.auth0lib = new Constructor(angular.extend(defaultOptions, options)); | ||
this.auth0lib = new constructorInfo.constructor(angular.extend(defaultOptions, options)); | ||
this.auth0js = this.auth0lib; | ||
this.isLock = false; | ||
this.lib = 'Auth0'; | ||
} | ||
@@ -263,2 +278,3 @@ this.initialized = true; | ||
popup: false, | ||
callbackOnLocationHash: true, | ||
connection: ssoData.lastUsedConnection.name | ||
@@ -265,0 +281,0 @@ }, null, null, 'Auth0'); |
/** | ||
* Angular SDK to use with Auth0 | ||
* @version v3.0.6 - 2014-12-19 | ||
* @version v4.0.1 - 2015-04-20 | ||
* @link https://auth0.com | ||
@@ -152,2 +152,27 @@ * @author Martin Gontovnikas | ||
} | ||
function constructorName(fun) { | ||
if (fun) { | ||
return { | ||
lib: authUtilsProvider.fnName(fun), | ||
constructor: fun | ||
}; | ||
} | ||
/* jshint ignore:start */ | ||
if (null != window.Auth0Lock) { | ||
return { | ||
lib: 'Auth0Lock', | ||
constructor: window.Auth0Lock | ||
}; | ||
} | ||
if (null != window.Auth0) { | ||
return { | ||
lib: 'Auth0', | ||
constructor: window.Auth0 | ||
}; | ||
} | ||
if (null != Auth0Widget) { | ||
throw new Error('Auth0Widget is not supported with this version of auth0-angular' + 'anymore. Please try with an older one'); | ||
} | ||
throw new Error('Cannott initialize Auth0Angular. Auth0Lock or Auth0 must be available'); /* jshint ignore:end */ | ||
} | ||
this.init = function (options, Auth0Constructor) { | ||
@@ -162,22 +187,12 @@ if (!options) { | ||
this.sso = options.sso; | ||
var Constructor = Auth0Constructor; | ||
if (!Constructor && typeof Auth0Lock !== 'undefined') { | ||
Constructor = Auth0Lock; | ||
} | ||
if (!Constructor && typeof Auth0 !== 'undefined') { | ||
Constructor = Auth0; | ||
} | ||
if (authUtilsProvider.fnName(Constructor) === 'Auth0Widget') { | ||
throw new Error('Auth0Widget is not supported with this ' + ' version of auth0-angular anymore. Please try with an older one'); | ||
} | ||
if (authUtilsProvider.fnName(Constructor) === 'Auth0Lock') { | ||
this.auth0lib = new Constructor(this.clientID, domain, angular.extend(defaultOptions, options)); | ||
var constructorInfo = constructorName(Auth0Constructor); | ||
this.lib = constructorInfo.lib; | ||
if (constructorInfo.lib === 'Auth0Lock') { | ||
this.auth0lib = new constructorInfo.constructor(this.clientID, domain, angular.extend(defaultOptions, options)); | ||
this.auth0js = this.auth0lib.getClient(); | ||
this.isLock = true; | ||
this.lib = 'Auth0Lock'; | ||
} else { | ||
this.auth0lib = new Constructor(angular.extend(defaultOptions, options)); | ||
this.auth0lib = new constructorInfo.constructor(angular.extend(defaultOptions, options)); | ||
this.auth0js = this.auth0lib; | ||
this.isLock = false; | ||
this.lib = 'Auth0'; | ||
} | ||
@@ -263,2 +278,3 @@ this.initialized = true; | ||
popup: false, | ||
callbackOnLocationHash: true, | ||
connection: ssoData.lastUsedConnection.name | ||
@@ -265,0 +281,0 @@ }, null, null, 'Auth0'); |
/** | ||
* Angular SDK to use with Auth0 | ||
* @version v3.0.6 - 2014-12-19 | ||
* @version v4.0.1 - 2015-04-20 | ||
* @link https://auth0.com | ||
@@ -152,2 +152,27 @@ * @author Martin Gontovnikas | ||
} | ||
function constructorName(fun) { | ||
if (fun) { | ||
return { | ||
lib: authUtilsProvider.fnName(fun), | ||
constructor: fun | ||
}; | ||
} | ||
/* jshint ignore:start */ | ||
if (null != window.Auth0Lock) { | ||
return { | ||
lib: 'Auth0Lock', | ||
constructor: window.Auth0Lock | ||
}; | ||
} | ||
if (null != window.Auth0) { | ||
return { | ||
lib: 'Auth0', | ||
constructor: window.Auth0 | ||
}; | ||
} | ||
if (null != Auth0Widget) { | ||
throw new Error('Auth0Widget is not supported with this version of auth0-angular' + 'anymore. Please try with an older one'); | ||
} | ||
throw new Error('Cannott initialize Auth0Angular. Auth0Lock or Auth0 must be available'); /* jshint ignore:end */ | ||
} | ||
this.init = function (options, Auth0Constructor) { | ||
@@ -162,22 +187,12 @@ if (!options) { | ||
this.sso = options.sso; | ||
var Constructor = Auth0Constructor; | ||
if (!Constructor && typeof Auth0Lock !== 'undefined') { | ||
Constructor = Auth0Lock; | ||
} | ||
if (!Constructor && typeof Auth0 !== 'undefined') { | ||
Constructor = Auth0; | ||
} | ||
if (authUtilsProvider.fnName(Constructor) === 'Auth0Widget') { | ||
throw new Error('Auth0Widget is not supported with this ' + ' version of auth0-angular anymore. Please try with an older one'); | ||
} | ||
if (authUtilsProvider.fnName(Constructor) === 'Auth0Lock') { | ||
this.auth0lib = new Constructor(this.clientID, domain, angular.extend(defaultOptions, options)); | ||
var constructorInfo = constructorName(Auth0Constructor); | ||
this.lib = constructorInfo.lib; | ||
if (constructorInfo.lib === 'Auth0Lock') { | ||
this.auth0lib = new constructorInfo.constructor(this.clientID, domain, angular.extend(defaultOptions, options)); | ||
this.auth0js = this.auth0lib.getClient(); | ||
this.isLock = true; | ||
this.lib = 'Auth0Lock'; | ||
} else { | ||
this.auth0lib = new Constructor(angular.extend(defaultOptions, options)); | ||
this.auth0lib = new constructorInfo.constructor(angular.extend(defaultOptions, options)); | ||
this.auth0js = this.auth0lib; | ||
this.isLock = false; | ||
this.lib = 'Auth0'; | ||
} | ||
@@ -263,2 +278,3 @@ this.initialized = true; | ||
popup: false, | ||
callbackOnLocationHash: true, | ||
connection: ssoData.lastUsedConnection.name | ||
@@ -265,0 +281,0 @@ }, null, null, 'Auth0'); |
/** | ||
* Angular SDK to use with Auth0 | ||
* @version v3.0.6 - 2014-12-19 | ||
* @version v4.0.1 - 2015-04-20 | ||
* @link https://auth0.com | ||
@@ -152,2 +152,27 @@ * @author Martin Gontovnikas | ||
} | ||
function constructorName(fun) { | ||
if (fun) { | ||
return { | ||
lib: authUtilsProvider.fnName(fun), | ||
constructor: fun | ||
}; | ||
} | ||
/* jshint ignore:start */ | ||
if (null != window.Auth0Lock) { | ||
return { | ||
lib: 'Auth0Lock', | ||
constructor: window.Auth0Lock | ||
}; | ||
} | ||
if (null != window.Auth0) { | ||
return { | ||
lib: 'Auth0', | ||
constructor: window.Auth0 | ||
}; | ||
} | ||
if (null != Auth0Widget) { | ||
throw new Error('Auth0Widget is not supported with this version of auth0-angular' + 'anymore. Please try with an older one'); | ||
} | ||
throw new Error('Cannott initialize Auth0Angular. Auth0Lock or Auth0 must be available'); /* jshint ignore:end */ | ||
} | ||
this.init = function (options, Auth0Constructor) { | ||
@@ -162,22 +187,12 @@ if (!options) { | ||
this.sso = options.sso; | ||
var Constructor = Auth0Constructor; | ||
if (!Constructor && typeof Auth0Lock !== 'undefined') { | ||
Constructor = Auth0Lock; | ||
} | ||
if (!Constructor && typeof Auth0 !== 'undefined') { | ||
Constructor = Auth0; | ||
} | ||
if (authUtilsProvider.fnName(Constructor) === 'Auth0Widget') { | ||
throw new Error('Auth0Widget is not supported with this ' + ' version of auth0-angular anymore. Please try with an older one'); | ||
} | ||
if (authUtilsProvider.fnName(Constructor) === 'Auth0Lock') { | ||
this.auth0lib = new Constructor(this.clientID, domain, angular.extend(defaultOptions, options)); | ||
var constructorInfo = constructorName(Auth0Constructor); | ||
this.lib = constructorInfo.lib; | ||
if (constructorInfo.lib === 'Auth0Lock') { | ||
this.auth0lib = new constructorInfo.constructor(this.clientID, domain, angular.extend(defaultOptions, options)); | ||
this.auth0js = this.auth0lib.getClient(); | ||
this.isLock = true; | ||
this.lib = 'Auth0Lock'; | ||
} else { | ||
this.auth0lib = new Constructor(angular.extend(defaultOptions, options)); | ||
this.auth0lib = new constructorInfo.constructor(angular.extend(defaultOptions, options)); | ||
this.auth0js = this.auth0lib; | ||
this.isLock = false; | ||
this.lib = 'Auth0'; | ||
} | ||
@@ -263,2 +278,3 @@ this.initialized = true; | ||
popup: false, | ||
callbackOnLocationHash: true, | ||
connection: ssoData.lastUsedConnection.name | ||
@@ -265,0 +281,0 @@ }, null, null, 'Auth0'); |
/** | ||
* Angular SDK to use with Auth0 | ||
* @version v3.0.6 - 2014-12-19 | ||
* @version v4.0.1 - 2015-04-20 | ||
* @link https://auth0.com | ||
@@ -152,2 +152,27 @@ * @author Martin Gontovnikas | ||
} | ||
function constructorName(fun) { | ||
if (fun) { | ||
return { | ||
lib: authUtilsProvider.fnName(fun), | ||
constructor: fun | ||
}; | ||
} | ||
/* jshint ignore:start */ | ||
if (null != window.Auth0Lock) { | ||
return { | ||
lib: 'Auth0Lock', | ||
constructor: window.Auth0Lock | ||
}; | ||
} | ||
if (null != window.Auth0) { | ||
return { | ||
lib: 'Auth0', | ||
constructor: window.Auth0 | ||
}; | ||
} | ||
if (null != Auth0Widget) { | ||
throw new Error('Auth0Widget is not supported with this version of auth0-angular' + 'anymore. Please try with an older one'); | ||
} | ||
throw new Error('Cannott initialize Auth0Angular. Auth0Lock or Auth0 must be available'); /* jshint ignore:end */ | ||
} | ||
this.init = function (options, Auth0Constructor) { | ||
@@ -162,22 +187,12 @@ if (!options) { | ||
this.sso = options.sso; | ||
var Constructor = Auth0Constructor; | ||
if (!Constructor && typeof Auth0Lock !== 'undefined') { | ||
Constructor = Auth0Lock; | ||
} | ||
if (!Constructor && typeof Auth0 !== 'undefined') { | ||
Constructor = Auth0; | ||
} | ||
if (authUtilsProvider.fnName(Constructor) === 'Auth0Widget') { | ||
throw new Error('Auth0Widget is not supported with this ' + ' version of auth0-angular anymore. Please try with an older one'); | ||
} | ||
if (authUtilsProvider.fnName(Constructor) === 'Auth0Lock') { | ||
this.auth0lib = new Constructor(this.clientID, domain, angular.extend(defaultOptions, options)); | ||
var constructorInfo = constructorName(Auth0Constructor); | ||
this.lib = constructorInfo.lib; | ||
if (constructorInfo.lib === 'Auth0Lock') { | ||
this.auth0lib = new constructorInfo.constructor(this.clientID, domain, angular.extend(defaultOptions, options)); | ||
this.auth0js = this.auth0lib.getClient(); | ||
this.isLock = true; | ||
this.lib = 'Auth0Lock'; | ||
} else { | ||
this.auth0lib = new Constructor(angular.extend(defaultOptions, options)); | ||
this.auth0lib = new constructorInfo.constructor(angular.extend(defaultOptions, options)); | ||
this.auth0js = this.auth0lib; | ||
this.isLock = false; | ||
this.lib = 'Auth0'; | ||
} | ||
@@ -263,2 +278,3 @@ this.initialized = true; | ||
popup: false, | ||
callbackOnLocationHash: true, | ||
connection: ssoData.lastUsedConnection.name | ||
@@ -265,0 +281,0 @@ }, null, null, 'Auth0'); |
/** | ||
* Angular SDK to use with Auth0 | ||
* @version v3.0.6 - 2014-12-19 | ||
* @version v4.0.1 - 2015-04-20 | ||
* @link https://auth0.com | ||
@@ -152,2 +152,27 @@ * @author Martin Gontovnikas | ||
} | ||
function constructorName(fun) { | ||
if (fun) { | ||
return { | ||
lib: authUtilsProvider.fnName(fun), | ||
constructor: fun | ||
}; | ||
} | ||
/* jshint ignore:start */ | ||
if (null != window.Auth0Lock) { | ||
return { | ||
lib: 'Auth0Lock', | ||
constructor: window.Auth0Lock | ||
}; | ||
} | ||
if (null != window.Auth0) { | ||
return { | ||
lib: 'Auth0', | ||
constructor: window.Auth0 | ||
}; | ||
} | ||
if (null != Auth0Widget) { | ||
throw new Error('Auth0Widget is not supported with this version of auth0-angular' + 'anymore. Please try with an older one'); | ||
} | ||
throw new Error('Cannott initialize Auth0Angular. Auth0Lock or Auth0 must be available'); /* jshint ignore:end */ | ||
} | ||
this.init = function (options, Auth0Constructor) { | ||
@@ -162,22 +187,12 @@ if (!options) { | ||
this.sso = options.sso; | ||
var Constructor = Auth0Constructor; | ||
if (!Constructor && typeof Auth0Lock !== 'undefined') { | ||
Constructor = Auth0Lock; | ||
} | ||
if (!Constructor && typeof Auth0 !== 'undefined') { | ||
Constructor = Auth0; | ||
} | ||
if (authUtilsProvider.fnName(Constructor) === 'Auth0Widget') { | ||
throw new Error('Auth0Widget is not supported with this ' + ' version of auth0-angular anymore. Please try with an older one'); | ||
} | ||
if (authUtilsProvider.fnName(Constructor) === 'Auth0Lock') { | ||
this.auth0lib = new Constructor(this.clientID, domain, angular.extend(defaultOptions, options)); | ||
var constructorInfo = constructorName(Auth0Constructor); | ||
this.lib = constructorInfo.lib; | ||
if (constructorInfo.lib === 'Auth0Lock') { | ||
this.auth0lib = new constructorInfo.constructor(this.clientID, domain, angular.extend(defaultOptions, options)); | ||
this.auth0js = this.auth0lib.getClient(); | ||
this.isLock = true; | ||
this.lib = 'Auth0Lock'; | ||
} else { | ||
this.auth0lib = new Constructor(angular.extend(defaultOptions, options)); | ||
this.auth0lib = new constructorInfo.constructor(angular.extend(defaultOptions, options)); | ||
this.auth0js = this.auth0lib; | ||
this.isLock = false; | ||
this.lib = 'Auth0'; | ||
} | ||
@@ -263,2 +278,3 @@ this.initialized = true; | ||
popup: false, | ||
callbackOnLocationHash: true, | ||
connection: ssoData.lastUsedConnection.name | ||
@@ -265,0 +281,0 @@ }, null, null, 'Auth0'); |
@@ -6,4 +6,4 @@ require.config({ | ||
'auth-angular': './auth0-angular', | ||
'angular-jwt': '//rawgit.com/auth0/angular-jwt/master/dist/angular-jwt', | ||
'angular-storage': '//rawgit.com/auth0/angular-storage/master/dist/angular-storage', | ||
'angular-jwt': '//cdn.rawgit.com/auth0/angular-jwt/master/dist/angular-jwt', | ||
'angular-storage': '//cdn.rawgit.com/auth0/angular-storage/master/dist/angular-storage', | ||
'auth0': '//cdn.auth0.com/w2/auth0-4' | ||
@@ -10,0 +10,0 @@ }, |
# SSO Example | ||
This example shows how to use SSO with Angular. The most important thing is to activate SSO on `authProvider` options. [Check this](https://github.com/auth0/auth0-angular/blob/master/examples/sso/scripts/myApp.js#L24-L34) | ||
This example shows how to use SSO with Angular. **The most important thing is to activate SSO on `authProvider` options. [Check this](https://github.com/auth0/auth0-angular/blob/master/examples/sso/scripts/myApp.js#L24-L34)** | ||
Also, you can check out [more information about SSO here](https://github.com/auth0/auth0-angular#using-sso) | ||
Also, you can check out [more information about SSO here](https://auth0.com/docs/sso/single-sign-on) and a full repository with both SPAs and Regular WebApp samples working with SSO [here](https://github.com/auth0/auth0-sso-sample) | ||
### Running the example | ||
In order to run the example, install `serve` to host static assets: | ||
```sh | ||
npm -g install serve | ||
``` | ||
In order to be able to test SSO correctly, you must have more than one application and each must have its own domain. For that, you can edit your `/etc/hosts` and make app1.com and app2.com point to `127.0.0.1`. | ||
Then execute on the example folder: | ||
```sh | ||
serve | ||
``` | ||
and point your browser to [http://localhost:3000/](http://localhost:3000). | ||
For that, open `/etc/hosts` and edits as follows: | ||
```` | ||
## | ||
# Host Database | ||
# | ||
# localhost is used to configure the loopback interface | ||
# when the system is booting. Do not change this entry. | ||
## | ||
127.0.0.1 localhost | ||
255.255.255.255 broadcasthost | ||
::1 localhost | ||
# ... | ||
127.0.0.1 app1.com | ||
```` | ||
Once that's done, just start this project twice in different ports. For that, we recommend using `serve` which is installed with `npm`by doing `npm i -g serve`. | ||
```` | ||
serve --port 3001 | ||
serve --port 3000 | ||
```` | ||
Now, you can go to `app1.com:3000`, login there and then go to `app2.com:3001`and you'll see that you're already logged in thanks to SSO :). |
/** | ||
* Angular SDK to use with Auth0 | ||
* @version v3.0.6 - 2014-12-19 | ||
* @version v4.0.1 - 2015-04-20 | ||
* @link https://auth0.com | ||
@@ -152,2 +152,27 @@ * @author Martin Gontovnikas | ||
} | ||
function constructorName(fun) { | ||
if (fun) { | ||
return { | ||
lib: authUtilsProvider.fnName(fun), | ||
constructor: fun | ||
}; | ||
} | ||
/* jshint ignore:start */ | ||
if (null != window.Auth0Lock) { | ||
return { | ||
lib: 'Auth0Lock', | ||
constructor: window.Auth0Lock | ||
}; | ||
} | ||
if (null != window.Auth0) { | ||
return { | ||
lib: 'Auth0', | ||
constructor: window.Auth0 | ||
}; | ||
} | ||
if (null != Auth0Widget) { | ||
throw new Error('Auth0Widget is not supported with this version of auth0-angular' + 'anymore. Please try with an older one'); | ||
} | ||
throw new Error('Cannott initialize Auth0Angular. Auth0Lock or Auth0 must be available'); /* jshint ignore:end */ | ||
} | ||
this.init = function (options, Auth0Constructor) { | ||
@@ -162,22 +187,12 @@ if (!options) { | ||
this.sso = options.sso; | ||
var Constructor = Auth0Constructor; | ||
if (!Constructor && typeof Auth0Lock !== 'undefined') { | ||
Constructor = Auth0Lock; | ||
} | ||
if (!Constructor && typeof Auth0 !== 'undefined') { | ||
Constructor = Auth0; | ||
} | ||
if (authUtilsProvider.fnName(Constructor) === 'Auth0Widget') { | ||
throw new Error('Auth0Widget is not supported with this ' + ' version of auth0-angular anymore. Please try with an older one'); | ||
} | ||
if (authUtilsProvider.fnName(Constructor) === 'Auth0Lock') { | ||
this.auth0lib = new Constructor(this.clientID, domain, angular.extend(defaultOptions, options)); | ||
var constructorInfo = constructorName(Auth0Constructor); | ||
this.lib = constructorInfo.lib; | ||
if (constructorInfo.lib === 'Auth0Lock') { | ||
this.auth0lib = new constructorInfo.constructor(this.clientID, domain, angular.extend(defaultOptions, options)); | ||
this.auth0js = this.auth0lib.getClient(); | ||
this.isLock = true; | ||
this.lib = 'Auth0Lock'; | ||
} else { | ||
this.auth0lib = new Constructor(angular.extend(defaultOptions, options)); | ||
this.auth0lib = new constructorInfo.constructor(angular.extend(defaultOptions, options)); | ||
this.auth0js = this.auth0lib; | ||
this.isLock = false; | ||
this.lib = 'Auth0'; | ||
} | ||
@@ -263,2 +278,3 @@ this.initialized = true; | ||
popup: false, | ||
callbackOnLocationHash: true, | ||
connection: ssoData.lastUsedConnection.name | ||
@@ -265,0 +281,0 @@ }, null, null, 'Auth0'); |
@@ -15,2 +15,8 @@ var myApp = angular.module('myApp'); | ||
$scope.auth = auth; | ||
$scope.login = function() { | ||
auth.signin({ | ||
responseType: 'token' | ||
}); | ||
} | ||
}); | ||
@@ -17,0 +23,0 @@ |
@@ -31,3 +31,3 @@ var myApp = angular.module('myApp', [ | ||
authProvider.on('loginSuccess', function($location, profilePromise, idToken) { | ||
authProvider.on('loginSuccess', function($location, profilePromise, idToken, store) { | ||
$location.path('/'); | ||
@@ -34,0 +34,0 @@ profilePromise.then(function(profile) { |
/** | ||
* Angular SDK to use with Auth0 | ||
* @version v3.0.6 - 2014-12-19 | ||
* @version v4.0.1 - 2015-04-20 | ||
* @link https://auth0.com | ||
@@ -152,2 +152,27 @@ * @author Martin Gontovnikas | ||
} | ||
function constructorName(fun) { | ||
if (fun) { | ||
return { | ||
lib: authUtilsProvider.fnName(fun), | ||
constructor: fun | ||
}; | ||
} | ||
/* jshint ignore:start */ | ||
if (null != window.Auth0Lock) { | ||
return { | ||
lib: 'Auth0Lock', | ||
constructor: window.Auth0Lock | ||
}; | ||
} | ||
if (null != window.Auth0) { | ||
return { | ||
lib: 'Auth0', | ||
constructor: window.Auth0 | ||
}; | ||
} | ||
if (null != Auth0Widget) { | ||
throw new Error('Auth0Widget is not supported with this version of auth0-angular' + 'anymore. Please try with an older one'); | ||
} | ||
throw new Error('Cannott initialize Auth0Angular. Auth0Lock or Auth0 must be available'); /* jshint ignore:end */ | ||
} | ||
this.init = function (options, Auth0Constructor) { | ||
@@ -162,22 +187,12 @@ if (!options) { | ||
this.sso = options.sso; | ||
var Constructor = Auth0Constructor; | ||
if (!Constructor && typeof Auth0Lock !== 'undefined') { | ||
Constructor = Auth0Lock; | ||
} | ||
if (!Constructor && typeof Auth0 !== 'undefined') { | ||
Constructor = Auth0; | ||
} | ||
if (authUtilsProvider.fnName(Constructor) === 'Auth0Widget') { | ||
throw new Error('Auth0Widget is not supported with this ' + ' version of auth0-angular anymore. Please try with an older one'); | ||
} | ||
if (authUtilsProvider.fnName(Constructor) === 'Auth0Lock') { | ||
this.auth0lib = new Constructor(this.clientID, domain, angular.extend(defaultOptions, options)); | ||
var constructorInfo = constructorName(Auth0Constructor); | ||
this.lib = constructorInfo.lib; | ||
if (constructorInfo.lib === 'Auth0Lock') { | ||
this.auth0lib = new constructorInfo.constructor(this.clientID, domain, angular.extend(defaultOptions, options)); | ||
this.auth0js = this.auth0lib.getClient(); | ||
this.isLock = true; | ||
this.lib = 'Auth0Lock'; | ||
} else { | ||
this.auth0lib = new Constructor(angular.extend(defaultOptions, options)); | ||
this.auth0lib = new constructorInfo.constructor(angular.extend(defaultOptions, options)); | ||
this.auth0js = this.auth0lib; | ||
this.isLock = false; | ||
this.lib = 'Auth0'; | ||
} | ||
@@ -263,2 +278,3 @@ this.initialized = true; | ||
popup: false, | ||
callbackOnLocationHash: true, | ||
connection: ssoData.lastUsedConnection.name | ||
@@ -265,0 +281,0 @@ }, null, null, 'Auth0'); |
/** | ||
* Angular SDK to use with Auth0 | ||
* @version v3.0.6 - 2014-12-19 | ||
* @version v4.0.1 - 2015-04-20 | ||
* @link https://auth0.com | ||
@@ -152,2 +152,27 @@ * @author Martin Gontovnikas | ||
} | ||
function constructorName(fun) { | ||
if (fun) { | ||
return { | ||
lib: authUtilsProvider.fnName(fun), | ||
constructor: fun | ||
}; | ||
} | ||
/* jshint ignore:start */ | ||
if (null != window.Auth0Lock) { | ||
return { | ||
lib: 'Auth0Lock', | ||
constructor: window.Auth0Lock | ||
}; | ||
} | ||
if (null != window.Auth0) { | ||
return { | ||
lib: 'Auth0', | ||
constructor: window.Auth0 | ||
}; | ||
} | ||
if (null != Auth0Widget) { | ||
throw new Error('Auth0Widget is not supported with this version of auth0-angular' + 'anymore. Please try with an older one'); | ||
} | ||
throw new Error('Cannott initialize Auth0Angular. Auth0Lock or Auth0 must be available'); /* jshint ignore:end */ | ||
} | ||
this.init = function (options, Auth0Constructor) { | ||
@@ -162,22 +187,12 @@ if (!options) { | ||
this.sso = options.sso; | ||
var Constructor = Auth0Constructor; | ||
if (!Constructor && typeof Auth0Lock !== 'undefined') { | ||
Constructor = Auth0Lock; | ||
} | ||
if (!Constructor && typeof Auth0 !== 'undefined') { | ||
Constructor = Auth0; | ||
} | ||
if (authUtilsProvider.fnName(Constructor) === 'Auth0Widget') { | ||
throw new Error('Auth0Widget is not supported with this ' + ' version of auth0-angular anymore. Please try with an older one'); | ||
} | ||
if (authUtilsProvider.fnName(Constructor) === 'Auth0Lock') { | ||
this.auth0lib = new Constructor(this.clientID, domain, angular.extend(defaultOptions, options)); | ||
var constructorInfo = constructorName(Auth0Constructor); | ||
this.lib = constructorInfo.lib; | ||
if (constructorInfo.lib === 'Auth0Lock') { | ||
this.auth0lib = new constructorInfo.constructor(this.clientID, domain, angular.extend(defaultOptions, options)); | ||
this.auth0js = this.auth0lib.getClient(); | ||
this.isLock = true; | ||
this.lib = 'Auth0Lock'; | ||
} else { | ||
this.auth0lib = new Constructor(angular.extend(defaultOptions, options)); | ||
this.auth0lib = new constructorInfo.constructor(angular.extend(defaultOptions, options)); | ||
this.auth0js = this.auth0lib; | ||
this.isLock = false; | ||
this.lib = 'Auth0'; | ||
} | ||
@@ -263,2 +278,3 @@ this.initialized = true; | ||
popup: false, | ||
callbackOnLocationHash: true, | ||
connection: ssoData.lastUsedConnection.name | ||
@@ -265,0 +281,0 @@ }, null, null, 'Auth0'); |
@@ -15,4 +15,9 @@ angular.module( 'sample.home', [ | ||
alert("We got the secured data successfully"); | ||
}, function() { | ||
alert("Please download the API seed so that you can call it."); | ||
}, function(response) { | ||
if (response.status == 0) { | ||
alert("Please download the API seed so that you can call it."); | ||
} | ||
else { | ||
alert(response.data); | ||
} | ||
}); | ||
@@ -19,0 +24,0 @@ } |
/** | ||
* Angular SDK to use with Auth0 | ||
* @version v3.0.6 - 2014-12-19 | ||
* @version v4.0.1 - 2015-04-20 | ||
* @link https://auth0.com | ||
@@ -152,2 +152,27 @@ * @author Martin Gontovnikas | ||
} | ||
function constructorName(fun) { | ||
if (fun) { | ||
return { | ||
lib: authUtilsProvider.fnName(fun), | ||
constructor: fun | ||
}; | ||
} | ||
/* jshint ignore:start */ | ||
if (null != window.Auth0Lock) { | ||
return { | ||
lib: 'Auth0Lock', | ||
constructor: window.Auth0Lock | ||
}; | ||
} | ||
if (null != window.Auth0) { | ||
return { | ||
lib: 'Auth0', | ||
constructor: window.Auth0 | ||
}; | ||
} | ||
if (null != Auth0Widget) { | ||
throw new Error('Auth0Widget is not supported with this version of auth0-angular' + 'anymore. Please try with an older one'); | ||
} | ||
throw new Error('Cannott initialize Auth0Angular. Auth0Lock or Auth0 must be available'); /* jshint ignore:end */ | ||
} | ||
this.init = function (options, Auth0Constructor) { | ||
@@ -162,22 +187,12 @@ if (!options) { | ||
this.sso = options.sso; | ||
var Constructor = Auth0Constructor; | ||
if (!Constructor && typeof Auth0Lock !== 'undefined') { | ||
Constructor = Auth0Lock; | ||
} | ||
if (!Constructor && typeof Auth0 !== 'undefined') { | ||
Constructor = Auth0; | ||
} | ||
if (authUtilsProvider.fnName(Constructor) === 'Auth0Widget') { | ||
throw new Error('Auth0Widget is not supported with this ' + ' version of auth0-angular anymore. Please try with an older one'); | ||
} | ||
if (authUtilsProvider.fnName(Constructor) === 'Auth0Lock') { | ||
this.auth0lib = new Constructor(this.clientID, domain, angular.extend(defaultOptions, options)); | ||
var constructorInfo = constructorName(Auth0Constructor); | ||
this.lib = constructorInfo.lib; | ||
if (constructorInfo.lib === 'Auth0Lock') { | ||
this.auth0lib = new constructorInfo.constructor(this.clientID, domain, angular.extend(defaultOptions, options)); | ||
this.auth0js = this.auth0lib.getClient(); | ||
this.isLock = true; | ||
this.lib = 'Auth0Lock'; | ||
} else { | ||
this.auth0lib = new Constructor(angular.extend(defaultOptions, options)); | ||
this.auth0lib = new constructorInfo.constructor(angular.extend(defaultOptions, options)); | ||
this.auth0js = this.auth0lib; | ||
this.isLock = false; | ||
this.lib = 'Auth0'; | ||
} | ||
@@ -263,2 +278,3 @@ this.initialized = true; | ||
popup: false, | ||
callbackOnLocationHash: true, | ||
connection: ssoData.lastUsedConnection.name | ||
@@ -265,0 +281,0 @@ }, null, null, 'Auth0'); |
@@ -6,3 +6,3 @@ { | ||
"author": "Martin Gontovnikas", | ||
"version": "4.0.0", | ||
"version": "4.0.2", | ||
"main": "./build/auth0-angular.js", | ||
@@ -41,3 +41,3 @@ "devDependencies": { | ||
"scripts": { | ||
"test": "grunt test -v" | ||
"test": "bower install && grunt test -v" | ||
}, | ||
@@ -44,0 +44,0 @@ "repository": { |
@@ -1,2 +0,2 @@ | ||
f# Auth0 and AngularJS | ||
# Auth0 and AngularJS | ||
@@ -71,3 +71,3 @@ This AngularJS module will help you implement client-side and server-side (API) authentication. You can use it together with [Auth0](https://www.auth0.com) to add support for username/password authentication, enterprise identity providers like Active Directory or SAML and also for social identity providers like Google, Facebook or Salesforce among others to your web, API and mobile native apps. | ||
} | ||
}, function() { | ||
}, function(profile, idToken, accessToken, state, refreshToken) { | ||
$location.path('/user-info') | ||
@@ -146,6 +146,6 @@ }, function(err) { | ||
````js | ||
auth.signin({}, function( | ||
auth.signin({}, function(profile, idToken, accessToken, state, refreshToken) { | ||
// All good | ||
$location.path('/'); | ||
), function(error) { | ||
}, function(error) { | ||
// Error | ||
@@ -163,6 +163,6 @@ }) | ||
connection: ['Username-Password-Authentication'] | ||
}, function( | ||
}, function() { | ||
// All good | ||
$location.path('/'); | ||
), function(error) { | ||
}, function(error) { | ||
// Error | ||
@@ -169,0 +169,0 @@ }) |
@@ -158,4 +158,34 @@ (function () { | ||
function constructorName(fun) { | ||
if (fun) { | ||
return { | ||
lib: authUtilsProvider.fnName(fun), | ||
constructor: fun | ||
}; | ||
} | ||
/* jshint ignore:start */ | ||
if (null != window.Auth0Lock) { | ||
return { | ||
lib: 'Auth0Lock', | ||
constructor: window.Auth0Lock | ||
}; | ||
} | ||
if (null != window.Auth0) { | ||
return { | ||
lib: 'Auth0', | ||
constructor: window.Auth0 | ||
}; | ||
} | ||
if (null != Auth0Widget) { | ||
throw new Error('Auth0Widget is not supported with this version of auth0-angular' + | ||
'anymore. Please try with an older one'); | ||
} | ||
throw new Error('Cannott initialize Auth0Angular. Auth0Lock or Auth0 must be available'); | ||
/* jshint ignore:end */ | ||
} | ||
this.init = function(options, Auth0Constructor) { | ||
@@ -171,25 +201,14 @@ if (!options) { | ||
var Constructor = Auth0Constructor; | ||
if (!Constructor && typeof Auth0Lock !== 'undefined') { | ||
Constructor = Auth0Lock; | ||
} | ||
if (!Constructor && typeof Auth0 !== 'undefined') { | ||
Constructor = Auth0; | ||
} | ||
if (authUtilsProvider.fnName(Constructor) === 'Auth0Widget') { | ||
throw new Error('Auth0Widget is not supported with this ' + | ||
' version of auth0-angular anymore. Please try with an older one'); | ||
} | ||
if (authUtilsProvider.fnName(Constructor) === 'Auth0Lock') { | ||
this.auth0lib = new Constructor(this.clientID, domain, angular.extend(defaultOptions, options)); | ||
var constructorInfo = constructorName(Auth0Constructor); | ||
this.lib = constructorInfo.lib; | ||
if (constructorInfo.lib === 'Auth0Lock') { | ||
this.auth0lib = new constructorInfo.constructor(this.clientID, domain, angular.extend(defaultOptions, options)); | ||
this.auth0js = this.auth0lib.getClient(); | ||
this.isLock = true; | ||
this.lib = 'Auth0Lock'; | ||
} else { | ||
this.auth0lib = new Constructor(angular.extend(defaultOptions, options)); | ||
this.auth0lib = new constructorInfo.constructor(angular.extend(defaultOptions, options)); | ||
this.auth0js = this.auth0lib; | ||
this.isLock = false; | ||
this.lib = 'Auth0'; | ||
} | ||
this.initialized = true; | ||
@@ -280,2 +299,3 @@ }; | ||
popup: false, | ||
callbackOnLocationHash: true, | ||
connection: ssoData.lastUsedConnection.name | ||
@@ -282,0 +302,0 @@ }, null, null, 'Auth0'); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
450780
7957