Revert change so that if the timeElapsed is less or equal to the max time their is no new email that is send.

This commit is contained in:
elweyn 2022-03-15 08:26:38 +01:00
parent f2e2c2d708
commit d4adb3b682

View File

@ -187,7 +187,7 @@ const getOptInCode = async (loginUserId: number): Promise<LoginEmailOptIn> => {
// Check for 10 minute delay
if (optInCode) {
const timeElapsed = Date.now() - new Date(optInCode.updatedAt).getTime()
if (timeElapsed < parseInt(CONFIG.EMAIL_CODE_VALID_TIME.toString()) * 60 * 1000) {
if (timeElapsed <= parseInt(CONFIG.EMAIL_CODE_VALID_TIME.toString()) * 60 * 1000) {
throw new Error(`email already sent less than $(CONFIG.EMAIL_CODE_VALID_TIME} minutes ago`)
} else {
optInCode.updatedAt = new Date()