Update backend/src/graphql/resolver/UserResolver.ts

Co-authored-by: Ulf Gebhardt <ulf.gebhardt@webcraft-media.de>
This commit is contained in:
Hannes Heine 2022-03-16 05:23:10 +01:00 committed by GitHub
parent e9ff0a8ed1
commit de88da40c1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -570,7 +570,7 @@ export class UserResolver {
@Query(() => Boolean)
async queryOptIn(@Arg('optIn') optIn: string): Promise<boolean> {
const optInCode = await LoginEmailOptIn.findOneOrFail({ verificationCode: optIn })
// Code is only valid for 10minutes
// Code is only valid for `CONFIG.EMAIL_CODE_VALID_TIME` minutes
const timeElapsed = Date.now() - new Date(optInCode.updatedAt).getTime()
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`)