Created
May 16, 2016 03:49
-
-
Save sandrinodimattia/7a2f35e1f57e05d489260b08a6cdaefa to your computer and use it in GitHub Desktop.
Auth0 Lock - Custom HRD
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script> | |
<script> | |
// Decode utf8 characters properly | |
var config = JSON.parse(decodeURIComponent(escape(window.atob('@@config@@')))); | |
var connection = config.connection; | |
var prompt = config.prompt; | |
var initializationOptions = { | |
assetsUrl: config.assetsUrl, | |
cdn: config.cdn | |
}; | |
var lock = new Auth0Lock(config.clientID, config.auth0Domain, initializationOptions); | |
lock.show({ | |
// icon: '{YOUR_LOGO_URL}', | |
callbackURL: config.callbackURL, | |
responseType: config.callbackOnLocationHash ? 'token' : 'code', | |
dict: config.dict, | |
connections: connection ? [connection] : null, | |
rememberLastLogin: !prompt, | |
container: 'widget-container', | |
authParams: config.internalOptions | |
}); | |
lock.once('signin ready', function(options) { | |
// Try to match a domain every time the users leaves the username field. | |
var emailField = $(lock.$container).find('input[name=email]').change(function() { | |
var username = $(this).val(); | |
// This would be a call to your API instead of hardcoding it. | |
if (username === '[email protected]') { | |
var apiResponse = { | |
connection: 'fabrikam-adfs' | |
}; | |
lock.$auth0.signin({ | |
connection: apiResponse.connection | |
}); | |
} | |
}); | |
}); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment