How to restrict access to individual pages in Node.JS?

I have it configured and working normally to restrict access to authorized users for the entire project.

But I need to limit the display of individual Content Pages to only some users.
What’s the easiest way to do this?

So far, I only came up with the idea of ​​​​creating for each such page a separate Server Action of the type “user1”, “user2” and …, in which to call Security Restrict with the appropriate permissions.

But maybe there is a better method?

I think the first question is what is the criteria for the restriction? Is it something like a role (e.g. admin vs user) or some other attribute of a user? I would attempt to use only one Server Action if possible as you want to reduce the amount of calls you need to process each time the page loads.

Secondly, I would restrict the data coming from the server connect as well as access to the page.

For the server connect you can setup conditions in your API to ensure that you only return the data where the user’s attributes meet the requirement.

You could also create a “Menu” table in your database and use that to load the appropriate menu items based on the user’s attribute(s). This way you remove the ability for the user to easily access the page they are not allowed to access.

I know how to restrict receiving data from the backend, but the question is, is it possible to somehow determine the rights of the current user in order to decide whether or not to show some part on the frontend?

Yes, it could be as simple as defining a column on the User table that you check in the Server Connect in an App Flow/Page Flow (if User only has “User” permission then use a Browser.goto to redirect them), or a more complex option like this.

Or without an App Flow/Page Flow, you could use a “Done” or “Success” event on the Server Connect and click on inline flow. Add a Condition, then a Run event to trigger the Browser.goto.

1 Like

Ok, but how to determine the current user on the server side is not very clear…

That’s just a Server Connect like this image. Add a Security Restrict and Security Identify. You can then add a Single Query to return the user record based on the Security Identify

1 Like

Many thanks for the help :slight_smile:

1 Like