cryptic
07/08/2022, 6:44 AMsignIn({})
method worksaar2dee2
07/08/2022, 6:56 AMcryptic
07/08/2022, 7:01 AMlogin with discord
button, it delivers a post request to the same route which is then handled by remix's ActionFunction
method that runs on server side. What I thought about doing from there is getting the url that is generated from the
ts
supabase.auth.signIn({
provider: 'discord',
});
method and the using the `ActionFunction`'s redirect()
method to redirect the user to it.
However, now that I'm thinking about it, I feel like I may be over complicating it drastically. My end goal was to have the user authenticated both on the server side and client side, that way I could use RLS from the server side as well.
I really hope that made sense, it's 3am here so I might be missing the mark lolaar2dee2
07/08/2022, 7:02 AMcryptic
07/08/2022, 7:03 AMaar2dee2
07/08/2022, 7:04 AMaar2dee2
07/08/2022, 7:04 AMaar2dee2
07/08/2022, 7:05 AMaar2dee2
07/08/2022, 7:08 AMts
export const getServerSideProps = withPageAuth({
redirectTo: "/auth/login",
async getServerSideProps(ctx) {
const provider_token = ctx.req.cookies["sb-provider-token"];
// Get logged in user's third-party id from metadata
const { user } = await getUser(ctx);
const { data } = await supabaseServerClient(ctx)
.from("profile")
.select("*")
.eq("auth_id", user.id)
.single();
return { props: { profile: data } };
},
});
this uses the withPageAuth
helper exposed by Supabase, so if there's no logged in user, the page redirects. I don't need additional functionality.