Skip to content

Conversation

@corburn
Copy link
Contributor

@corburn corburn commented Nov 4, 2014

This PR adds event.preventDefault() to the $on('$stateChangeStart) Auth intercept because it fixed an intermittent bug in my code.

I made the following change in my code:

// Before:
if (next.authenticate && !loggedIn) {
    $location.path('/login');
}

// After
if (!loggedIn && next.name !== 'login') {
      event.preventDefault();
      $state.go('login');
}

Before adding event.preventDefault(), the state intercept would intermittently fail to redirect the user to the login view. Specifically when clicking links. Adding event.preventDefault() fixed the problem.

Awk34 added a commit that referenced this pull request Jun 16, 2015
fix(app): Add event.preventDefault to login redirect
@Awk34 Awk34 merged commit f6f912f into angular-fullstack:master Jun 16, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants