#Baepsae
1 messages · Page 1 of 1 (latest)
I have done something like this inside the App compoenent isAuthorized ? <MainViews userContext={userContext} /> : <Auth environment={environment} />
That's not something you'd define in the app manifest, but inside your React components: https://stripe.com/docs/stripe-apps/oauth#set-and-find-access-token
But it doesn't work for me with the concept of navigation
Hi @brittle stratus , thank you for the quick reply (:
I understand authorization is not something I do through the stripe-app.json file, in this file it's where we define the viewports and provide each of them with a component to show.
I don't understand though, how I go on about conditioning if the user is not authorized in whichever viewport, they will see the authorization screen
Not sure what you mean. You'd write some logic in your authenticated views to check the store for a token, and if they're not authenticated/authorised then redirect back to your auth view
So for each view component should I have a isAuthorized state?
Let's say this is the DashboardView component, it should look like this?
isAuthorized ? <Dashboard /> : <Auth />
And then say we have AnalyticsView component, it should look like this?
isAuthorized ? <Analytics /> : <Auth />
Just thought maybe I could wrap the authorized views like I originally did in the code I sent here in the thread previously, but I guess that's not possible?
I haven't seen the previous thread
I mean this thread
This code
isAuthorized ? <MainViews userContext={userContext} /> : <Auth environment={environment} />
And MainViews component includes all the authorized views
Yes I suspect that doesn't work. There's an example here that you could draw some inspiration from: https://github.com/stripe/stripe-apps/blob/main/examples/basic-auth/frontend/src/views/App.tsx