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

How to access the response from the $auth.submitLogin()? #304

Closed
pierrettemugisha opened this issue Jul 14, 2016 · 1 comment
Closed

How to access the response from the $auth.submitLogin()? #304

pierrettemugisha opened this issue Jul 14, 2016 · 1 comment

Comments

@pierrettemugisha
Copy link

Hello there,

I was wondering if there is away to access and parse the response from the $auth.submitLogin() function. I am sending a json abject from my java service which contains the token, the username and last-accessed-time, but when I try to see what I have in the my response in the console I get this: {signedIn: true, configName: "default"} but in the network when I preview my response I see the object I send from my service. How come my two response are different? I am new in all of this (java and angular) it's been like two months that I started jave and a month for angular, and I can't figure out how I can access this response as I want to get that response and have it when I route to another view.

Thank you in advance for the response

@colmben
Copy link

colmben commented Dec 19, 2016

Just in case anybody gets here via a search, I had a similar issue and can offer some insights. Looking at the code, a resolved object of {signedIn: true, configName: "default"} after submit login means that the code wasn't able to extract a user object from the response. It then extends the empty user object to add in the configName and signedIn elements. In my case this was caused by me using a custom json response from the devise-token-auth server side. It turns out that the json response has to be wrapped in an outer data: element. If ng-auth-token doesn't see a data element then it doesn't get the user info. So for example in jBuilder, you would have something like this :

json.data do
json.(@resource,
    :id,
    :email,
    :fullname,
    :country_code,
    :language_code,
    :last_sign_in_at,
    :sign_in_count,
    :provider,
    :uid)
end

Note I'm not great on jBuilder so there may be a more efficient way to that the outer wrapper but you get the point.

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

2 participants