New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ngx-permissions - NgxPermissionsGuard routing issue redirect to default route. #25
Comments
You can customize redirection with function and write your custom logic there
|
I know this redirection method but wanted to stay on current page after page refresh. |
Do you load permissions on page refresh? https://github.com/AlexKhymenko/ngx-permissions/wiki/common-use-cases#save-permissions-on-page-refresh |
After user is logged in then i set permission from get token which is work as expected but when user refresh any component after login then it's redirect to default route. |
You need to save them forexample in local Storage and the load them before application starts. The problem is when you refresh the page all data is lost including permissions and the application need them back. so the best way is to save to localStorage and then load again. |
I used localstorage to set the user object and get userobject but i assigned logged user role to ngx permission and then we used in route. |
Just need 2 answers.
|
No i don't have this permission on starting on the app. assigning permission after user login |
So the problem is. When user logins you assign permissions everything is good. But then you refresh and the whole data is lost including permissions. The user triest to access the page. Router checkes the permissions for him to view the page. There are no permissions there. User redirects to another page. So You need to save permissions on login to localStorate. And before app starts load them to ngxPermissionsService again. |
Current behavior
We have 3 child route and 1 root route
I used to build angular 4 application with nodejs we have 2 admin panel, 1 site and app.module.ts we used for lazy loading, ngx-permissions, NgxPermissionsGuard.
After the user login from oneadmin they can access every route but if user is in dashboard user can't able to refresh page, if user refresh page it's redirect to http://127.0.0.1:3000.
http://127.0.0.1:3000/oneadmin/dashboard
http://127.0.0.1:3000/oneadmin/profile
here is route code
Expected behavior
if user refresh the page it want redirect to to anywhere just stay them in to current page.
http://127.0.0.1:3000/oneadmin/dashboard
Environment
The text was updated successfully, but these errors were encountered: