🔒 Add rate limiter on email signin endpoint

This commit is contained in:
Baptiste Arnaud
2023-06-20 15:49:54 +02:00
parent 3b52363e11
commit 7c2e5740dc
8 changed files with 104 additions and 14 deletions

View File

@@ -72,17 +72,24 @@ export const SignInForm = ({
e.preventDefault()
if (isMagicLinkSent) return
setAuthLoading(true)
const response = await signIn('email', {
email: emailValue,
redirect: false,
})
if (response?.error) {
showToast({
title: scopedT('signinErrorToast.title'),
description: scopedT('signinErrorToast.description'),
try {
const response = await signIn('email', {
email: emailValue,
redirect: false,
})
if (response?.error) {
showToast({
title: scopedT('signinErrorToast.title'),
description: scopedT('signinErrorToast.description'),
})
} else {
setIsMagicLinkSent(true)
}
} catch {
showToast({
status: 'info',
description: scopedT('signinErrorToast.tooManyRequests'),
})
} else {
setIsMagicLinkSent(true)
}
setAuthLoading(false)
}