Last active
January 29, 2020 22:52
-
-
Save SumanaMalkapuram/b53a6985029dcc2543139074a2290863 to your computer and use it in GitHub Desktop.
Skip rule for silent Auth
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) { | |
let timeLimitMs = 1000; | |
let currentDate = new Date(); | |
let currentTimeMs = currentDate.getTime(); | |
let last_auth_time = new Date(context.authentication.methods.find((method) => method.name === 'pwd').timestamp); | |
let lastAuthTimeMs = last_auth_time.getTime(); | |
const isSilentAuth = currentTimeMs - lastAuthTimeMs > timeLimitMs ? true : false; | |
console.log("current time", currentTimeMs); | |
console.log("lastAuthTime", lastAuthTimeMs); | |
console.log("difference", isSilentAuth); | |
console.log("auth methods", context.authentication.methods); | |
if (!isSilentAuth) { | |
// bla bla logic to post to APIs | |
console.log("not silent", context); | |
callback(null, user, context); | |
} else { | |
console.log("in silent and not posting to API", context); | |
callback(null, user, context); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment