Last active
May 8, 2019 16:41
-
-
Save Tanver-Hasan/ddf48b9a4703e4dd1f64cc42a8c2e9f6 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) { | |
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