Created
March 14, 2018 16:07
-
-
Save saltukalakus/74026b039db34f97c06642e8a6f50048 to your computer and use it in GitHub Desktop.
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
function (user, context, callback) { | |
var deviceFingerPrint = getDeviceFingerPrint(); | |
user.app_metadata = user.app_metadata || {}; | |
if (user.app_metadata.lastLoginDeviceFingerPrint !== deviceFingerPrint) { | |
user.app_metadata.lastLoginDeviceFingerPrint = deviceFingerPrint; | |
context.multifactor = { | |
allowRememberBrowser: false, | |
provider: 'guardian' | |
}; | |
auth0.users.updateAppMetadata(user.user_id, user.app_metadata) | |
.then( function() { | |
callback(null, user, context); | |
}) | |
.catch( function(err) { | |
callback(err); | |
}); | |
} else { | |
callback(null, user, context); | |
} | |
function getDeviceFingerPrint() { | |
var shasum = crypto.createHash('sha1'); | |
shasum.update(context.request.userAgent); | |
shasum.update(context.request.ip); | |
return shasum.digest('hex'); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment