Skip to content

Instantly share code, notes, and snippets.

@abbaspour
Created October 28, 2021 00:01
Show Gist options
  • Save abbaspour/e64c71f2b8286ab170aa9a664e1fef3d to your computer and use it in GitHub Desktop.
Save abbaspour/e64c71f2b8286ab170aa9a664e1fef3d to your computer and use it in GitHub Desktop.
redirect from UL to specific connection
<!DOCTYPE html>
<html>
<head>
<script src="//cdn.jsdelivr.net/lodash/4.17.4/lodash.core.min.js"></script>
<script src="//cdn.auth0.com/js/auth0/8.12.2/auth0.min.js"></script>
</head>
<body>
<script>
// standard config decoding as in the default template
var config = JSON.parse(decodeURIComponent(escape(window.atob('@@config@@'))));
// When CNAME is used, config.authorizationServer points to the CNAME auth0 domain.
var auth0ServerDomain = config.authorizationServer ? config.authorizationServer.url.replace('https://', '') : config.auth0Domain;
// builds an Auth0.js instance using config options
var authClient = new auth0.Authentication({
domain: auth0ServerDomain,
clientID: config.clientID,
_disableDeprecationWarnings: true,
redirectUri: config.callbackURL,
responseType: config.extraParams.response_type || config.callbackOnLocationHash ? 'token' : 'code'
});
// build an authorize URL specifying a connection
var buildDirectAuthUrl = function (connectionName) {
// using lodash to extend config.internalOptions with the connectionName
var options = _.extend({}, config.internalOptions, {
connection: connectionName
});
return authClient.buildAuthorizeUrl(options);
};
location.href = buildDirectAuthUrl(config.dict.signin.title === 'auth0-delegated-admin-spa' ? 'Care' : 'Other');
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment