Skip to content

Features/anna mandatory user info - #35

Closed
anna-harrington-7 wants to merge 3 commits into
mainfrom
features/anna-mandatory-user-info
Closed

Features/anna mandatory user info#35
anna-harrington-7 wants to merge 3 commits into
mainfrom
features/anna-mandatory-user-info

Conversation

@anna-harrington-7

Copy link
Copy Markdown
Collaborator

Description

If user hasn't filled out their personal info yet, they get redirected to the "user info" page. They can't go to the homepage, they'll get redirected. They also cannot type a url into the address bar. They can click on their profile and navigate those pages, though.

How to use

In order to change that, those client pages will need a prop called "infoFilled" and look like this

(client page)
const { status, data: sessionData } = useSession();
const router = useRouter();

useEffect(() => {
if (status === "authenticated" && sessionData?.user && !infoFilled) {
router.replace("/create-account/basic-info");
}
}, [status, sessionData, router, events]);

(server page)
const session = await auth();
const userId = session?.user?.id ?? null;

let infoFilled = true;

if (session?.user) {
const [user] = await db
.select()
.from(users)
.where(eq(users.id, session.user.id))
.limit(1);

if (user) {
  infoFilled = user.info_filled;
}

}

then use the prob infoFilled when calling the client page.

@AgustinSV AgustinSV closed this Mar 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants