msy
04/29/2022, 5:03 AMconst { user: authUser } = await supabase.auth.api.getUserByCookie(req);
// Check if the user is logged
if (authUser === null) {
// Redirect if no logged in
return { props: {}, redirect: { destination: "/" } };
}
// If logged return the user
let { user, error } = await supabase.from("users").select("id, first_name");
console.log("user", authUser);
if (user) {
return { props: { user: user } };
} else {
return { props: {}, redirect: { destination: "/" } };
}
I read on the supabase documentation that with the set policies I wouldn't need to filter and I could directly do .from("users") and get the relevant row from the public users table, with the primary key set as a foreign key to the auth.users table
Note: authUser is returning the correct value.Needle
04/29/2022, 5:03 AM/title
command!
We have solved your problem?
Click the button below to archive it.msy
04/29/2022, 5:04 AMNeedle
04/29/2022, 5:04 AMNeedle
04/29/2022, 5:06 AMNeedle
04/29/2022, 5:14 AMgaryaustin
04/29/2022, 3:42 PMNeedle
04/29/2022, 3:42 PM