Merge branch 'master' into 2594-filter-query-all-contributions

This commit is contained in:
Hannes Heine 2023-02-01 13:46:46 +01:00 committed by GitHub
commit cc4ff9c4b7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 14 deletions

View File

@ -96,7 +96,7 @@ describe('EmailOptinCodes', () => {
mutate({ mutation: forgotPassword, variables: { email: 'peter@lustig.de' } }),
).resolves.toMatchObject({
data: null,
errors: [new GraphQLError('email already sent less than 10 minutes minutes ago')],
errors: [new GraphQLError('email already sent less than 10 minutes ago')],
})
})

View File

@ -830,7 +830,7 @@ describe('UserResolver', () => {
new GraphQLError(
`email already sent less than ${printTimeDuration(
CONFIG.EMAIL_CODE_REQUEST_TIME,
)} minutes ago`,
)} ago`,
),
],
}),
@ -870,13 +870,13 @@ describe('UserResolver', () => {
CONFIG.EMAIL_CODE_REQUEST_TIME = emailCodeRequestTime
await expect(mutate({ mutation: forgotPassword, variables })).resolves.toEqual(
expect.objectContaining({
errors: [new GraphQLError('email already sent less than 10 minutes minutes ago')],
errors: [new GraphQLError('email already sent less than 10 minutes ago')],
}),
)
})
it('logs the error found', () => {
expect(logger.error).toBeCalledWith(`email already sent less than 10 minutes minutes ago`)
expect(logger.error).toBeCalledWith(`email already sent less than 10 minutes ago`)
})
})
})

View File

@ -392,16 +392,11 @@ export class UserResolver {
}
if (!canEmailResend(user.emailContact.updatedAt || user.emailContact.createdAt)) {
logger.error(
`email already sent less than ${printTimeDuration(
CONFIG.EMAIL_CODE_REQUEST_TIME,
)} minutes ago`,
)
throw new Error(
`email already sent less than ${printTimeDuration(
CONFIG.EMAIL_CODE_REQUEST_TIME,
)} minutes ago`,
)
const errorMessage = `email already sent less than ${printTimeDuration(
CONFIG.EMAIL_CODE_REQUEST_TIME,
)} ago`
logger.error(errorMessage)
throw new Error(errorMessage)
}
user.emailContact.updatedAt = new Date()