feat: rate limiter

This commit is contained in:
Bereket Engida
2024-09-18 14:20:09 +03:00
parent 6c69b804d2
commit 1554e770b4
13 changed files with 478 additions and 42 deletions

View File

@@ -32,10 +32,15 @@ export async function SignInButton() {
}
function checkOptimisticSession(headers: Headers) {
const guessIsSignIn = headers.get("cookie")?.includes("better-auth.session") || headers.get("cookie")?.includes("__Secure-better-auth.session-token")
return !!guessIsSignIn;
}
export function SignInFallback() {
//to avoid flash of unauthenticated state
const guessIsSignIn = headers().get("cookie")?.includes("better-auth.session") || headers().get("cookie")?.includes("__Secure-better-auth.session-token")
const guessIsSignIn = checkOptimisticSession(headers())
return (
<Link href={
guessIsSignIn ? "/dashboard" : "/sign-in"