question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

HELP : When refresh page its redirect on dashboard

See original GitHub issue

i have check permission on route. its working file. thanks for your time. my issue is i load permission list when application startup.
for ex
my current page http://localhost:4200/#/app/users. now i refresh page redirect on dashboard instead of stay on current page. but i don’t know how to resolve this issue. i also try to-load-permissions-before-application-start-up . please help me. Thanks in advance

 component: UsersComponent,
        children: [
            {
                path: '',
                component: UsersListComponent,
                pathMatch: 'full',
                canActivate: [NgxPermissionsGuard],
                data: {
                    permissions: {
                        only: 'read_user',
                        redirectTo: ConfigConstant.DEFAULT_ROUTE
                    },
                    title: 'Users · Life AI'
                }
            },

Angular version:4.0.2 ngx-permissions version: ^1.0.0

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:10 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
we125182commented, Dec 5, 2017

@AlexKhymenko thank you for you response. and now i found what the problem is. it’s a bug on angular CanActivate guards on child routes run before parent CanActivate guards finish. it fixed in version 4.3.2

0reactions
we125182commented, Dec 5, 2017

oh, because i set a judgement to decide which flow i will use. Look at this

public hasGetUserInfo(state) {
    if (this.appConfig.hasGetAuthInfo) {
      return this._isActivate(state);
    } else {
      // return this._waitUtilGetInfo(state);
      return this._getUserInfo();
    }
  }

when refresh page the variable this.appConfig.hasGetAuthInfo is false. so the function _isActivate wouldn’t run. After getting the user info and permissions, it will change to true. and In this moment, function _isActive will run.

Read more comments on GitHub >

github_iconTop Results From Across the Web

3 Ways to Fix WordPress Login Refreshing & Redirecting
1. Clear Your Browser Cookies and Cache. The quickest way to solve the WordPress login redirect issue is by clearing your browser cookies...
Read more >
Redirect to dashboard on refresh if user is logged in React ...
First thing, in your useEffect, you are re-directing to /dashboard . However, in here <Route path="/dashboard" element={<PrivateRoute ...
Read more >
How to Fix WordPress Login Page Refreshing ... - WPBeginner
Incorrect WordPress URL settings and failure to set login cookies are the most common reasons causing the login page redirect and refresh issue....
Read more >
Redirected temporarily to login page after refresh
The browser redirects to the login page for a few seconds, and then back to the original page. I'm using a ProtectedRoute component...
Read more >
Redirect doesn't work – user not logged until page reload
It sounds like an issue with the Cache control headers. Cache control headers are set either by the host or some caching plugin,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found