Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Does validateUser() reload $auth.user from the backend? #176

Closed
davidtlee opened this issue Jul 15, 2015 · 4 comments
Closed

Does validateUser() reload $auth.user from the backend? #176

davidtlee opened this issue Jul 15, 2015 · 4 comments

Comments

@davidtlee
Copy link

In my app, I have a phone_verified boolean column on user. If the user has verified their phone, I route them to the main app, if not, I route them to an onboarding process.

Right now, after a user goes through onboarding, I can see that u.phone_verified is true for that user (through the rails console). However, on the frontend, it still believes that u.phone_verified is false. The place where I route the user is within an $auth.validateUser() callback, so I was thinking that the user object within the callback should be updated. But an alert(user.phone_verified) indicates that this column is still false.

So my question is: Does $auth.validateUser() go to the server and get the user object? If not, how can I get the user object?

Other configuration notes that might be relevant just in case:

  • In my devise_token_auth setup, I set config.change_headers_on_each_request = false
  • I wrote on override for the omniauth_callbacks_controller#omniauth_success action and the omniauth_response.html.erb and omniauth_success.html.erb templates

Thanks!

@angelxmoreno
Copy link
Contributor

I am also interested in how/where the lib updates the $auth.user. I am using a NodeJS backend. On page refresh I lose the details passed by $auth.authenticate().

@angelxmoreno
Copy link
Contributor

after reading the ReadMe several times, I noticed https://github.com/lynndylanhurley/ng-token-auth#using-alternate-response-formats says what I am doing wrong.

Basically, the validate_token endpoint needs to have a data param with the user data.
@davidtlee please confirm this fixes your issue.

@booleanbetrayal
Copy link
Collaborator

Closing this since it seems like the issue has been worked out. Please let me know if I need to re-open @davidtlee

@davidtlee
Copy link
Author

Hey @angelxmoreno and @booleanbetrayal, sorry for being so MIA with responding.

@angelxmoreno: I don't think that's my issue, because I use devise-token-auth, which should already be using the correct format.

@angelxmoreno and @booleanbetrayal: that being said, I haven't really seen this bug lately (only happens with creating a new user and I haven't really tested that recently). I think we can keep this closed. When I get back to it, I'll dig into it more if the bug still exists and reopen the issue if applicable. Thanks!

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

No branches or pull requests

3 participants