Created
August 29, 2018 02:40
-
-
Save abbaspour/37c7f7c0178e8a05c42227325395d5b8 to your computer and use it in GitHub Desktop.
Auth0 Lock Plugin Example
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
var myPlugin = (function () { | |
var _webAuth | |
var ctor = function MyPlugIn() { | |
var _this = this | |
this.args = arguments | |
this.supports = function (extensibilityPoint) { | |
console.log(extensibilityPoint) | |
return false | |
} | |
this.init = function () { | |
} | |
} | |
ctor.version = '9.5.1' | |
ctor.setWebAuth = function (webAuth) { | |
_webAuth = webAuth | |
var originalLogin = _webAuth.login | |
_webAuth.login = function (options, cb) { | |
var newOptions = JSON.parse(JSON.stringify(options)) | |
newOptions.username = domain + '|' + newOptions.username | |
return originalLogin.call(_webAuth, newOptions, cb) | |
} | |
} | |
return ctor | |
})() | |
var lock = new Auth0Lock(config.clientID, config.auth0Domain, { | |
auth: { | |
redirectUrl: config.callbackURL, | |
responseType: (config.internalOptions || {}).response_type || | |
(config.callbackOnLocationHash ? 'token' : 'code'), | |
params: config.internalOptions | |
}, | |
assetsUrl: config.assetsUrl, | |
allowedConnections: connection ? [connection] : null, | |
rememberLastLogin: !prompt, | |
language: language, | |
theme: { | |
}, | |
prefill: loginHint ? { email: loginHint, username: loginHint } : null, | |
closable: false, | |
plugins: [myPlugin] | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment