Hello everyone, I hope you are doing well! I have a question. I have a table that contains sub-tables. The values of the main table are loaded from the backend, while for the subtables, I have a list in the TypeScript file, and each element has several sub-elements. The problem is that there are elements for which the user must have a specific role to access them, but they are displayed.
My question is: how to display a message when the user clicks on one of these elements? I want to be able to know if he clicks on it, and if the user has the rights, he will be redirected to a page. How to proceed for this?
Top comments (2)
The solution to this problem is to check the user’s role before redirecting them to a new page in the guard. I created a guard where I check their role. If they are authorized, I redirect them; otherwise, an error message is displayed.
Feels good to find the solution doesn't! Onward you go, Chakir! Thanks for sharing the solution.