rateLimit using database isn't working

I'm trying to setup rateLimit with database. After generating the schema & pushing to the database, I try signing in/changing password in the client a lot (That should trigger rateLimit) but it doesn't work for some reason. Here is my options.rateLimit:
rateLimit: {
enabled: true,
storage: "database",
},
rateLimit: {
enabled: true,
storage: "database",
},
signing in:
await authClient.signIn.email({
email: contactInfo,
password,
fetchOptions: {
onSuccess: async (ctx) => {
const { data } = await authClient.getSession();
router.push(getAuthRoutingDirectory(data?.user));
},
onError: (ctx) => {
if (ctx.error.code === "BANNED_USER") {
router.push(BANNED_ROUTE);
return;
} else if (ctx.error.code === "EMAIL_NOT_VERIFIED") {
authClient.emailOtp.sendVerificationOtp({
email: contactInfo,
type: "email-verification",
fetchOptions: {
onSuccess: () => {
localStorage.setItem("verification-email", contactInfo);
router.push("/auth/email-verification");
},
onError: (ctx) => {
setError(ctx.error.message);
},
},
});
return;
}
setError(ctx.error.message);
},
},
});
await authClient.signIn.email({
email: contactInfo,
password,
fetchOptions: {
onSuccess: async (ctx) => {
const { data } = await authClient.getSession();
router.push(getAuthRoutingDirectory(data?.user));
},
onError: (ctx) => {
if (ctx.error.code === "BANNED_USER") {
router.push(BANNED_ROUTE);
return;
} else if (ctx.error.code === "EMAIL_NOT_VERIFIED") {
authClient.emailOtp.sendVerificationOtp({
email: contactInfo,
type: "email-verification",
fetchOptions: {
onSuccess: () => {
localStorage.setItem("verification-email", contactInfo);
router.push("/auth/email-verification");
},
onError: (ctx) => {
setError(ctx.error.message);
},
},
});
return;
}
setError(ctx.error.message);
},
},
});
1 Reply
Maqed
MaqedOP4mo ago
Note: I'm using better-auth 1.2.8

Did you find this page helpful?