-
Notifications
You must be signed in to change notification settings - Fork 14
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
@_shield
memoization doesn't remove authenticated state for user
#24
Comments
I'm suspecting |
Good point, I'm using Unicorn (Worker/Multi processes/single thread). |
Can you try this? module Shield
private
class ThreadSafeHash
def initialize
@hs = Hash.new
end
def hs
@hs[Thread.current.object_id] ||= Hash.new
end
def [](key)
hs[key]
end
def []=(key, value)
hs[key] = value
end
def delete(key)
hs.delete(key)
end
end
end Then, in def authenticated(model)
@_shield ||= ThreadSafeHash.new
@_shield[model] ||= session[model.to_s] && model[session[model.to_s]]
end |
I tryed, but it doesn't fix the problem on logout with Unicorn, works with WEBrick. It's probably because of workers. Don't know if there is a good solution for that ? |
I use Shield in rack application with Syro. On logout, I suspect that
@_shield
memoization persist the authenticate state of user.For now I remove
@_shield
memoization and it works :https://github.com/fenicks/forgedtofight.io/blob/master/decks/basic_deck.rb#L9.
Is it safe to do so ?
The text was updated successfully, but these errors were encountered: