Hi I am using api to authencticate and then storing user info in session .
My layout is
├── app
│ │ │ ├── (auth)
│ │ │ │ ├── login
│ │ │ │ └── register
│ │ │ │ ├── details
│ │ │ │ └── otp
│ │ │ ├── (nav-layout)
│ │ │ │ ├── bookings
│ │ │ │ │ ├── cancelled
│ │ │ │ │ └── completed
│ │ │ │ ├── info
│ │ │ │ │ └── [id]
│ │ │ │ │ └── payment
│ │ │ │ │ └── success
│ │ │ │ └── support
│ │ │ │ ├── solved
│ │ │ │ └── upcomming
│ │ │ └── api
│ │ │ └── auth
│ │ │ ├── login
│ │ │ └── register
My login functionality looks like this :
const onSubmit = (payload: TRegistrationSchema) => {
const promise = registrationMutation
.mutateAsync(payload)
.then(() => loginMutation.mutateAsync(payload))
.then(() => router.push("/"));
toast.promise(promise, {
loading: "Please wait ...",
success: "Registration successful !!",
error: (err) => err.message || "Something went wrong !!",
});
};
My navigation is server compoennt which checks login status using a server action
export const Navigation = async () => {
const session = await getSession();
console.log("SESSION FROM NAV", session)
// Checks session and render element based on session is null or object
};
export async function getSession() {
const session = cookies().get("session")?.value;
if (!session) return null;
try {
return await decrypt(session);
} catch (err) {
return null;
}
}
Here is the get session function
WHen I do signin then I am redirected to root but my nav stays same