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

No Headers after sign_in for new Users created by Admin #685

Closed
BrahimDahmani opened this issue Jul 26, 2016 · 5 comments
Closed

No Headers after sign_in for new Users created by Admin #685

BrahimDahmani opened this issue Jul 26, 2016 · 5 comments

Comments

@BrahimDahmani
Copy link

BrahimDahmani commented Jul 26, 2016

I've created several admin-users, you can refer to the Create action in AdminUsersController as it's mentioned below, and when i tried to sign-in i didn't get the desired Headers such as "access_token, expiry,uid..."

def create
      admin_user = AdminUser.new admin_user_params

      if admin_user.save
        render json: admin_user , status: :created
      else
        render json: admin_user.errors , status: :unprocessable_entity
      end
end

Request

[POST] http://api.myapp.local:3000/admin/sign_in

//header
Accept:application/vnd.myapp.v1
Content-Type:application/json

//data
{
    "email": "[email protected]",
    "password": "password"
}

Response:

Access-Control-Allow-Credentials →true
Access-Control-Allow-Methods →GET, POST, OPTIONS, DELETE, PUT
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 →no-cache
Content-Type →application/json; charset=utf-8
Transfer-Encoding →chunked
Vary →Origin
X-Content-Type-Options →nosniff
X-Frame-Options →SAMEORIGIN
X-Request-Id →bbc8662d-644f-4819-a074-9efc7dce2dc3
X-Runtime →0.069372
X-XSS-Protection →1; mode=block
@BrahimDahmani
Copy link
Author

any help here??

@biomancer
Copy link
Contributor

biomancer commented Aug 2, 2016

I faced the same issue, for some reason @client_id that is set in sessions_controller does not keep its value here https://github.com/lynndylanhurley/devise_token_auth/blob/master/app/controllers/devise_token_auth/concerns/set_user_by_token.rb#L89

@biomancer
Copy link
Contributor

biomancer commented Aug 2, 2016

And I've found that this has broken after I added 'active_model_serializers' gem to gemfile.
It adds call to current_user to build serialization_scope, and current_user calls set_user_by_token and that ruins everything, as it must not be called before update_auth_header

@biomancer
Copy link
Contributor

I do not need that scope, so in my case adding
serialization_scope nil to ApplicationController fixed the issue.

@BrahimDahmani
Copy link
Author

thank you so match, your solution worked perfectly.

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