Authentication not working on secure pages

Hi… I needed some help…
So basically I wanna implement custom auth…

So i have configured an integration to make api calls to my backend.

I authenticate & run ensurePlasmicAppUser() & then const { user: plasmicUser, token: plasmicUserToken } = result;

Then save token to cookies like >> res.setHeader(‘Set-Cookie’, token=${plasmicUserToken}; HttpOnly; Secure; SameSite=Strict;);

But when i try to access the pages which require min role as normal user… They still say

You don’t have access to this page <<

do i have to do something with the plasmicUser or Token…

what to do so that my app recognises the user ?

cc: @fmota

Hi @illuminating_egret are you providing your user and token to the PlasmicRootProvider ? As it’s being shown in this example https://github.com/plasmicapp/plasmic/blob/fca35655e7b175e26560ca009cb398060a6ab0d[…]/examples/supabase-auth-nextjs-pages-loader/pages/ssr/index.tsx

Is this true for codegen also?

Can i create components & exporting proops to plasmicrootprovider

Yes, you also need to pass the user/token in codegen, as in https://github.com/plasmicapp/plasmic/blob/fca35655e7b175e26560ca009cb398060a6ab0d4/examples/supabase-auth-nextjs-pages-codegen/pages/ssr.tsx

Sorry I didn’t understood what you meant with:

Can i create components & exporting proops to plasmicrootprovider

Basically i want to create components… & Use props to pass custom variables… Because lets say i wrote a custom code inside the wrapper of a component…now how don i make the component interact with that custom code … How do i pass the pros in plasmic studio

Hello…

I have one more question… When we call ensureplasmicuser function & it returns user & token… & then if we pass it to PlasmicRootProvider like >>

Does it handle saving plasmicUser & plasmicUserToken to the cookies & recovering it when accessed by the user ?

If you are using custom auth, you would have to handle saving/recovering plasmicUser/plasmicUserToken, the won’t do that for you