$auth & angular-ui-router [resolved]

Hello all, after almost a week of try I ask help to the community

Combined with angular-ui-router (in the resolve object) $auth.loggingIn refuse to trigger to true automatically like it’s indicated in the API doc

  • Result: It gives, when I enter a valid password, a empty area where I should see a list (coming from DB). When I go to another page and I comeback “the list is there!” …but when I reload the page, empty area again

When I explicitly put $auth.loggingIn = true; in the resolve object.

  • Result: No more pb with the display of the list “but” the resolve object no more play it’s role of filter (ex: user1 can access to user2 element and vice-versa)

I used several combinations of $auth functions unsuccessfully.
The screenshot give the first result until a better solution

Thanks for your help

After another serie of try I noticed a random display of the list when I refresh the page. Sound like a delay issue isn’t it ?! :wink:

I let this post on if someone else need the solution
ps: under 200 the delay issue comeback

So you’re trying to wait for a user to login but if not do not pass in the user object? Your if statement is wrong from what I can tell.

If you’re too lazy (like I am) to do o == v1 || o == v2 || o == v3 you can use

appUsers.slice(0,3).indexOf(user._id)  !== -1

Also why not just get the user object and deal with it on the controller?

resolve: {
  user: $auth => $auth.awaitUser()
controller: function( user ) {
   if (appUsers.slice(0,3).indexOf(user._id)  !== -1) { ... }
1 Like

Hi @trajano, thanks for your reply

  • Love your use of array methods, much elegant than my previous line!
  • about $auth.awaitUser() still on 0.2 I will upgrade and try