atmos / warden-github

:lock: warden strategy for github oauth
MIT License
54 stars 41 forks source link

Persist membership cache between requests #53

Closed fphilipe closed 7 years ago

fphilipe commented 7 years ago

The membership cache was being serialized into the user object. It was assumed that the user object was serialized at the end of each request. It turns out that this is not the case. Instead, the user object only gets serialized once, namely after setting the user. This means that the membership cache wasn't working at all between requests.

This commit fixes it by not including the memberships in the serialized user as there's no point in doing so. Instead, after the user object is set up, the memberships hash get retrieved from the user session (warden provides a session object for each scope; if there is none, a new hash is stored in the session) and assigned to the user object. The hash is then used as before and we get the session serialization from rack for free.

Fixes #52.

atmos commented 7 years ago

Hi @fphilipe,

Any idea what's up with the rack error? I think this was something common in upgrades like 2-3 years ago.

fphilipe commented 7 years ago

Hey @atmos. Do you mean rack or rake? 😊 The error in the build is fixed by my other PR #54. I'd rebase this PR on top of the other once that one is merged, or I can combine them into one PR, as you prefer.

Also, I just bumped the patch version number, since this change is completely backwards compatible. The old serialization format that included the memberships field of the struct would still deserialize correctly.

atmos commented 7 years ago

1.3.2 is live on rubygems.org

fphilipe commented 7 years ago

Thanks @atmos!