How do you show ban reason and expiry on a banned page?
Hey everyone, quick question!
I'm using Better-Auth with Next.js, and I have a before hook that redirects banned users to a /banned page:
hooks: {
before: createAuthMiddleware(async (ctx) => {
if (ctx.path === "/error" && ctx.query?.error === "banned") {
throw ctx.redirect("/banned");
}
}),
}
This works, but the issue is: the /banned page just shows a generic message. I’d like to show the actual ban reason and maybe the ban expiry time, but I’m not sure how to get that info from Better-Auth.
Has anyone done this before?
Is there a way to pass the ban details to the banned page (like via query params, cookie, or session)?
Or should I be using an after hook instead?
What’s the cleanest way you all handle this?
Would love to hear how others are doing it. Thanks! 🙏1 Reply
[Issue]: Redirect banned user to a custom page after login in with OAuth (Google)
I didnt goof out there and wrote solution to mix of your problem and theirs