fix: 🐛 address pr comments
This commit is contained in:
@@ -29,6 +29,12 @@ export default function Hero() {
|
||||
const containerRef = useRef(null);
|
||||
const heroTlRef = useRef(null);
|
||||
const [displayedText, setDisplayedText] = useState("");
|
||||
const [isLoggedIn, setIsLoggedIn] = useState(false);
|
||||
|
||||
// Read the hint cookie after mount to avoid SSR/CSR hydration mismatch.
|
||||
useEffect(() => {
|
||||
setIsLoggedIn(getLoggedInHintCookie() === true);
|
||||
}, []);
|
||||
|
||||
// Badge typewriter
|
||||
useEffect(() => {
|
||||
@@ -208,7 +214,13 @@ export default function Hero() {
|
||||
<div className="flex flex-nowrap items-center xl:px-22.75 px-4 bg-[#0F0F0F] w-full overflow-hidden">
|
||||
{/* Primary CTA */}
|
||||
<div className="hero-cta w-full md:w-fit md:flex-shrink-0">
|
||||
<Link href={"https://app.useautumn.com/sign-in"}>
|
||||
<Link
|
||||
href={
|
||||
isLoggedIn
|
||||
? "https://app.useautumn.com"
|
||||
: "https://app.useautumn.com/sign-in"
|
||||
}
|
||||
>
|
||||
<motion.div
|
||||
initial="initial"
|
||||
whileHover="hover"
|
||||
@@ -219,7 +231,7 @@ export default function Hero() {
|
||||
<div className="relative overflow-hidden flex items-center gap-1.5 md:gap-2.5 cursor-pointer justify-between py-2 px-3 md:px-4 md:py-3.5 md:w-50 font-sans bg-[#9564ff] hover:bg-[#7D46F4] transition-colors duration-300">
|
||||
<CTALines />
|
||||
<span className="relative z-10 tracking-[-2%] uppercase md:normal-case text-white font-medium text-[12px] md:text-base whitespace-nowrap">
|
||||
{getLoggedInHintCookie() ? "Dashboard" : "Start for free"}
|
||||
{isLoggedIn ? "Dashboard" : "Start for free"}
|
||||
</span>
|
||||
<span className="relative z-10 scale-95 md:scale-100">
|
||||
<IconCTAStart />
|
||||
|
||||
@@ -20,6 +20,7 @@ import { sendOnboardingEmail } from "@/internal/emails/sendOnboardingEmail.js";
|
||||
import sendOTPEmail from "@/internal/emails/sendOTPEmail.js";
|
||||
import { afterOrgCreated } from "./authUtils/afterOrgCreated.js";
|
||||
import { afterSessionCreated } from "./authUtils/afterSessionCreated.js";
|
||||
import { afterSessionDeleted } from "./authUtils/afterSessionDeleted.js";
|
||||
import { beforeSessionCreated } from "./authUtils/beforeSessionCreated.js";
|
||||
import { ADMIN_USER_IDs } from "./constants.js";
|
||||
|
||||
@@ -53,6 +54,11 @@ export const auth = betterAuth({
|
||||
return afterSessionCreated(session, context);
|
||||
},
|
||||
},
|
||||
delete: {
|
||||
after: (session, context) => {
|
||||
return afterSessionDeleted(session, context);
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
user: {
|
||||
|
||||
29
server/src/utils/authUtils/afterSessionDeleted.ts
Normal file
29
server/src/utils/authUtils/afterSessionDeleted.ts
Normal file
@@ -0,0 +1,29 @@
|
||||
import type { GenericEndpointContext } from "@better-auth/core";
|
||||
import type { BetterAuthOptions, Session } from "better-auth";
|
||||
|
||||
export const afterSessionDeleted = async (
|
||||
_session: Session,
|
||||
context: GenericEndpointContext<BetterAuthOptions> | null,
|
||||
) => {
|
||||
try {
|
||||
if (!context) return;
|
||||
|
||||
// Dev parity: the cookie is only set server-side in production, so
|
||||
// we don't need to clear it here in other environments.
|
||||
if (process.env.NODE_ENV !== "production") return;
|
||||
|
||||
// Clear the landing-page hint cookie so signed-out users stop seeing
|
||||
// the "Dashboard" CTA on useautumn.com. Attributes must match the
|
||||
// original setCookie call so the browser overwrites the cookie.
|
||||
context.setCookie("logged_in_hint", "", {
|
||||
domain: ".useautumn.com",
|
||||
path: "/",
|
||||
maxAge: 0,
|
||||
secure: true,
|
||||
sameSite: "none",
|
||||
httpOnly: false,
|
||||
});
|
||||
} catch (_) {
|
||||
console.error("Error running afterSessionDeleted", { error: _ });
|
||||
}
|
||||
};
|
||||
@@ -59,11 +59,9 @@ export default function App() {
|
||||
document.cookie =
|
||||
"logged_in_hint=1; path=/; max-age=604800; SameSite=Lax";
|
||||
} else {
|
||||
document.cookie =
|
||||
"logged_in_hint=; path=/; max-age=0; SameSite=Lax";
|
||||
document.cookie = "logged_in_hint=; path=/; max-age=0; SameSite=Lax";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}, [data]);
|
||||
return (
|
||||
|
||||
Reference in New Issue
Block a user