Best way to restrict pages to logged in users only
See original GitHub issueAny pointers on redirecting users who try to access a route that is for logged in users only? Here’s what I have so far in routes.js:
// const user is either true or false, and passes that in as a prop to the app
on('*', async (state, next) => {
const component = await next();
const user = await http.get(`/api2/user`);
return component && <App context={state.context} user={user}>{component}</App>;
});
I feel like the redirection should happen somewhere in this file, rather than inside <App /> somewhere, is it something to do with the on('error'...
function? Though I’d rather redirect users to a login page and not a 404.
<bountysource-plugin>
Want to back this issue? Post a bounty on it! We accept bounties via Bountysource. </bountysource-plugin>
Issue Analytics
- State:
- Created 8 years ago
- Comments:5
Top Results From Across the Web
How to Restrict WordPress Pages by User Role - WPBeginner
On the edit screen, scroll down to 'Restrict this content' meta box and select 'Members with certain role' option. Restrict content by user...
Read more >Tutorial: WordPress Restrict Page Access to Logged In Users
Profile Builder: The Easiest Way to Restrict Page Access to Logged-in Users in WordPress. Profile Builder gives you a simple way to customize ......
Read more >Content Control – User Access Restriction Plugin
Content Control is a lightweight and powerful plugin that allows you to take complete control of your website's content by restricting access to...
Read more >5 WordPress Plugins that Restrict User Access to Content
5 plugins to restrict user access in WordPress · 1. Restrict User Access · 2. Restrict Content · 3. User Access Manager ·...
Read more >How to Restrict WordPress Content to Specific Users
Restrict individual form fields based on visibility settings. · Use hidden fields and conditional logic. · Create a View that restricts access to ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
In my case, I use redux. You can add this to
src/routes/index.js
orsrc/routes/yourroute/index.js
Oh I forgot all about this. In the end I just validated with a token, and redirected users if the response from the API was a 403.