i create a web application with angualr 8 .
i need to guard or routes and pages with dynamic accessLevel .
for example i check in the route , if user have access to this route , open it but shout he/she into the login page .
i have this list and i save it in local storage and every time need to check the AccessLevel i get all list from localstorage and check it .
now i think the local storage not a good place for save securityInfo .
every body have suggestion for best and secyre place for save this info ?????
Ideally for this you should have to have seperate API. And from the your angular application. You can use CanActivate
route guard and eachtime when use trying to go to a specific page you can check it for access.
Another option is to keep a global service
maintained to keeping user access data. Once after the user logs in fetch data from the backend of your applciation(One time API call) and store it in the global data service variable and returned it as a observable when ever you needs it. Whenever the user accessing a specific route check for the relevent authorization in you angular application. Since the global data service
is available at the root
level it will have access to all the components
thorughout.
Another approach is create and store the authorization details in NgRxStore
. And use those values stored in it when user accessing a specific route
.
我认为您可以为此目的创建 API。然后在决定访问级别时,您可以为此调用 API
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.