Created
February 2, 2018 07:38
-
-
Save xkisu/643aeb14b2621d78952f17efde0127ce to your computer and use it in GitHub Desktop.
This file contains 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
function (user, context, callback) { | |
var uuid = require("uuid"); | |
user.app_metadata = user.app_metadata || {}; | |
var promise = Promise.resolve(1); | |
if (!user.app_metadata.uuid) { | |
user.app_metadata.uuid = uuid(); | |
promise = auth0.users.updateAppMetadata(user.user_id, user.app_metadata); | |
} | |
promise.then(() => { | |
if (context.idToken) { | |
// Include the uuid in the issued ID token if applicable | |
context.idToken["http://kobu.io/uuid"] = user.app_metadata.uuid; | |
} | |
if (context.accessToken) { | |
// Include the uuid in the issued access token if applicable | |
context.accessToken["http://kobu.io/uuid"] = user.app_metadata.uuid; | |
} | |
callback(null, user, context); | |
}).catch(callback); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment