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

current_user seems to be nil after doing requests from different tabs #579

Closed
lucas-aragno opened this issue Mar 17, 2016 · 3 comments
Closed

Comments

@lucas-aragno
Copy link

Hey,

I'm testing out this gem and seems that the current_user variable disappears after several requests

on my application_controller I have

...
  include DeviseTokenAuth::Concerns::SetUserByToken
  protect_from_forgery with: :null_session
  before_filter :show_user

  def show_user
    Rails.logger.debug "==== #{current_user.inspect}"
  end

...

navigating trough the app this are the outputs of that logger

==== #<User id: ...
==== #<User id: ...
==== #<User id: ...
==== nil
==== nil

I'm also tailing the controllers involved

Processing by Admin::Api::SomethingController#index as JSON
Processing by Admin::Api::SomethingController#index as JSON
Processing by HomeController#index as HTML
Processing by Admin::Api::SomethingController#index as JSON

I'm not seeing anything weird but on the last call to the SomethingController I get

Filter chain halted as :authenticate_user! rendered or redirected

but at that point the current_user is nil already

any thoughts?

@rohitsiddha
Copy link

I'm facing the same issue. In my case the scenario is bit different, I've a scaled architecture, where there are 5 API servers has been placed behind a load balancer, all are connected with a common db server. When I do batch requests, requests are being routed to different API servers by load balancer. However I get following message as a response from the second request-
Authorized users only

Any thought about how to use this gem with scaled architecture?

@lucas-aragno
Copy link
Author

I've solved this issue doing a little rework over the devise.rb initializer could you share yours? perhaps I can help.

@lucas-aragno
Copy link
Author

Closing this issue now

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