Skip to content

Instantly share code, notes, and snippets.

@Tanver-Hasan
Last active May 8, 2019 16:41
Show Gist options
  • Save Tanver-Hasan/ddf48b9a4703e4dd1f64cc42a8c2e9f6 to your computer and use it in GitHub Desktop.
Save Tanver-Hasan/ddf48b9a4703e4dd1f64cc42a8c2e9f6 to your computer and use it in GitHub Desktop.
function (user, context, callback) {
function daydiff (first, second) {
return (second-first)/(1000*60*60*24);
}
const last_password_change = user.last_password_reset || user.created_at;
if (daydiff(new Date(last_password_change), new Date()) > 30) {
return callback(new UnauthorizedError('please change your password'));
}
callback(null, user, context);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment