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

Heroku $rootScope.user get wrapper by 'user' #89

Closed
vs-zhang opened this issue Jan 7, 2015 · 11 comments
Closed

Heroku $rootScope.user get wrapper by 'user' #89

vs-zhang opened this issue Jan 7, 2015 · 11 comments

Comments

@vs-zhang
Copy link

vs-zhang commented Jan 7, 2015

HI @lynndylanhurley
When i deploy the sample app the heroku, the $rootScope.user have a very interesting bugs. I don't know that just me or what. Since in the localhost, the $rootScope is fine, it will be like

{_id: 123, name: 'abc', "email":"[email protected]","provider":"email","uid":"123456","signedIn":true,"configName":"default"} 

But in heroku production env, it will be like

{user: {_id: 123, name: 'abc', "email":"[email protected]","provider":"email","uid":"123456"},"signedIn":true,"configName":"default"} 

as u can see, the $rootScope.user get wrapper

@lynndylanhurley
Copy link
Owner

What was the response from the $auth.signIn() / $auth.authenticate() method?

@vs-zhang
Copy link
Author

vs-zhang commented Jan 8, 2015

screen shot 2015-01-07 at 10 57 59 pm

@vs-zhang
Copy link
Author

vs-zhang commented Jan 8, 2015

that's the response from the heroku, in localhost is fine. And i know the demo is host in heroku, and that seems fine. Let me console.log more out to track what's going on. Total no idea

@lynndylanhurley
Copy link
Owner

That looks like the javascript $auth.user object. What was the response body from the server for the login request?

@vs-zhang
Copy link
Author

vs-zhang commented Jan 8, 2015

screen shot 2015-01-07 at 11 15 20 pm

This is the response back from the /api/auth/sign_in

@lynndylanhurley
Copy link
Owner

The server shouldn't be wrapping the data within a user object. Any idea why that's happening?

@vs-zhang
Copy link
Author

vs-zhang commented Jan 8, 2015

screen shot 2015-01-07 at 11 18 51 pm

and this is the response back from the localhost /api/auth/sign_in

@lynndylanhurley
Copy link
Owner

So the problem is clearly with the API. Are both heroku and your local app running the same code (same app code, same gem versions, etc.)?

@vs-zhang
Copy link
Author

vs-zhang commented Jan 8, 2015

the issue i found is so funny right now, since i am using a custom sessions_controller and i see the @resource is the same in local and heroku, they both like <user _id:'123', name: abc>, but when the next block

render json:{
          data: @resource.as_json(except: [
            :tokens, :created_at, :updated_at
          ])
}}

that's the fun start
in localhost it like
{:data=>{"_id"=>123, "email"=>"[email protected]", "name"=>"abc", "provider"=>"email"}
in heroku it like
{:data=>user=>{"_id"=>123, "email"=>"[email protected]", "name"=>"abc", "provider"=>"email"}}

Localhost:
screen shot 2015-01-08 at 12 13 57 am

Heroku:
screen shot 2015-01-08 at 12 13 37 am

@vs-zhang vs-zhang closed this as completed Jan 8, 2015
@vs-zhang
Copy link
Author

vs-zhang commented Jan 8, 2015

@lynndylanhurley Thanks for all the help, the problem is the mongoid.yml in production session turn on the include_root_in_json: true, LOL

@lynndylanhurley
Copy link
Owner

Ahh no problem! 😃

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