0

I'm trying to create a parent state in my Route definition to handle Autorization like this:

$stateProvider.state('root', {
  abstract: true,
  resolve: {
  auth: ['Auth',
    function (Auth) {
      return Auth.authorize()
    }
  ]}
})

this parent state is defined in my other states like this:

.state('home', {
  parent: 'root',
  url: '/',
  templateUrl: 'views/home.html',
  controller: 'HomeCtrl'
})

From my understanding of parent states and this post it should work just like this.

The Auth.authorize method works fine, since I can do a simple resolve on each state. Here's the function:

function authorize() {
    var user = getCurrentUser();
    if (user)  return $q.when(user);
    else {
        $timeout(function() {
            $state.go('login')
        });
        return $q.reject();
    }
}

The response is ok, but the page doesn't get displayed. What am I missing here?

Community
  • 1
  • 1
Markus
  • 1,565
  • 6
  • 26
  • 57

0 Answers0