next state controller is loaded before redirect to login

53 views Asked by At

I am have used angular fullstack yeoman generator to generate my site's starting point.
I am facing a problem with redirecting the user to a login page when he accesses a restricted page - what seems to happen is that the controller of the restricted page is loaded before the redirect. Its important to say that the problem only happens after building for distribution via grunt.

I didn't change much of the original generated code:

  Auth.isLoggedInAsync(function (loggedIn) {
    if (next.authenticate && !loggedIn) {
      // store the requested url if not logged in
      if ($location.url() != '/login') {
        $cookies.put('returnUrl', $location.url());
      }
      $location.path('/login');
    }
  }
0

There are 0 answers