Do i need to logout from supabase sdk? #10
-
Hi, thank you for making this remix stack, really helpful to understand how to integrate Supabase with Remix. I have a question about the following code: // app/routes/logout.tsx
export const action: ActionFunction = async ({ request }) => {
assertIsPost(request);
return destroyAuthSession(request);
}; if I understand it correctly, the logout action only deletes or resets the session cookie. A logout from supabase via the sdk is not performed here. Other examples, like from dijonmusters or VictorPeralta do it however in such a way: export let loader: LoaderFunction = async ({ request }) => {
return clearCookie(request);
};
export default function Logout() {
const navigate = useNavigate();
useEffect(() => {
const logoutUser = async () => {
await supabase.auth.signOut();
navigate("/");
};
logoutUser();
}, []);
return null;
} the supabase docs says:
i think this is not need, because the stack doesn't relay on localstorage
would it make sense to use this function of supabase, or is that invalid because the session has already been deleted? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
Thanks 🙏 In my stack I use supabase sdk with service role (full power, bypass RLS). So, user is not linked to supabase and we don't need to use supabase's logout function. The user session lives in session cookie. So removing it (Remix side) will logout user. |
Beta Was this translation helpful? Give feedback.
Thanks 🙏
In my stack I use supabase sdk with service role (full power, bypass RLS).
It's one super instance for all requests, assuming that developers handle security check (who can access what, and doesn't rely on RLS features).
So, user is not linked to supabase and we don't need to use supabase's logout function.
The user session lives in session cookie. So removing it (Remix side) will logout user.
It works only because this stack provides ways to assert that a user is logged (read cookie and challenge tokens)