C
C#2y ago
adc90

❔ Authentication with blazor pre-rendered

I'm doing Authentication in blazor, we're using ProtectedBrowserStorage to store the user object. As such when I render components OnInitializedAsync I don't have access to the user object as it's stored client side. Is it the pattern to just do setup of a component OnAfterRenderAsync or is there a way to have access to the user object in OnInitializedAsync. I was thinking I could keep it in a server cookie but I'm not sure how to go about that.
3 Replies
friedice
friedice2y ago
you could create an appstateservice that persists throughout the app, make a getter or some kind of way to obtain the user object, and just use that this way you can just inject appstate into whatever component you need without calling your method to grab the userobject each time you initialize a new component
adc90
adc90OP2y ago
Kind of like cascasding app state? Maybe that's what I need and I'm using it wrong, my issue seems simple so I think I'm missing something obvious CascadingAuthorizationState*
Accord
Accord2y ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server