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

I'am not able to serialize user #769

Closed
BrahimDahmani opened this issue Nov 14, 2016 · 4 comments
Closed

I'am not able to serialize user #769

BrahimDahmani opened this issue Nov 14, 2016 · 4 comments

Comments

@BrahimDahmani
Copy link

BrahimDahmani commented Nov 14, 2016

I had overridden the sessions_controller

#app/controllers/v1/user/devise_overrides/sessions_controller.rb

module V1
  module User
    module DeviseOverrides
      class SessionsController < DeviseTokenAuth::SessionsController
        protected
        def render_create_success
          render json: {data: ::UserSerializer.new(@resource)}, status: :ok
        end
      end
    end
  end
end

I got the serialized user correctlly

{
  "data": {
    "id": 1,
    "email": "[email protected]",
    "image": {
      "image": {
        "url": null
      }
    },
    "provider": "email",
    "uid": "[email protected]",
    "profile": {
      "id": 11,
      "title": null,
      "first_name": "user",
      "last_name": "user",
      "display_name": "user user",
      "martial_status": null,
      "birthday": null,
      "facebook": null,
      "twitter": null,
      "gplus": null,
      "updated_at": "2016-08-10T15:40:13.280Z",
      "user_id": 1,
      "user_type": "User"
    },
    "commune": {
      "id": 1,
      "name": "commune",
      "description": "commune descripttionnennenenenenn",
      "lat": "48.858093",
      "lng": "2.294694",
      "zoom": 15
    }
  }
}

but without headers

Access-Control-Allow-Credentials →true
Access-Control-Allow-Methods →GET, POST, PUT, PATCH, DELETE, OPTIONS
Access-Control-Allow-Origin →chrome-extension://fhbjgbiflinjbdggehcddcbncdddomop
Access-Control-Expose-Headers →access-token, expiry, token-type, uid, client
Access-Control-Max-Age →1728000
Cache-Control →max-age=0, private, must-revalidate
Content-Type →application/json; charset=utf-8
ETag →W/"54623aaeee6543d357a19042d51196ca"
Transfer-Encoding →chunked
Vary →Origin
X-Content-Type-Options →nosniff
X-Frame-Options →SAMEORIGIN
X-Request-Id →1f7ebfc4-b252-406b-82aa-c5e75eb1eaa6
X-Runtime →0.446054
X-XSS-Protection →1; mode=block

also, I tried this solution

 #app/models/user.rb
def token_validation_response                                                                                                                                         
  UserSerializer.new(self).as_json
end

and

#app/controllers/v1/user/devise_overrides/sessions_controller.rb
def render_create_success
  render json: {
    data: resource_data(resource_json: @resource.token_validation_response)
  }
end

always no headers

i'm using:
rails 5.0.0.1
AMS 0.10.2 (from github)
devise_token_auth 0.1.37 (tried 0.1.38,0.1.39)
devise 4.2.0

@Motaso
Copy link

Motaso commented Nov 15, 2016

hello Same issu !

@BrahimDahmani
Copy link
Author

any help, please?

@jgoodall628
Copy link

I am seeing the same issue but only in production I am not seeing headers. Locally it works just fine.

@zachfeldman
Copy link
Contributor

Hi there @jgoodall628 , @BrahimDahmani ,

In an effort to cleanup this project and prioritize a bit, we're marking issues that haven't had any activity in a while with a "close-in-7-days" label. If we don't hear from you in about a week, we'll be closing this issue. Obviously feel free to re-open it at any time if it's the right time or this was done in error!

If you are still having the issue (especially if it's a bug report) please refer to our new Issue Template to provide some more details to help us solve it.

Hope all is well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants