-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Create a model hook around the lockable warden hook to reset attempts #5369
Conversation
28a4cf8
to
fa15f8b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome. Thank you for taking this on, my apologies for not getting to it sooner! I think this change will help a lot of Rails 6 users with a replica database setup.
d5c8fdb
to
68da1d8
Compare
This looks great and not as complicated as I thought it would be. Kudos for tackling this problem! It is the one thing that prevents me from making full (and easy) use of the replica reads. |
We've been using this change in production and haven't seen any exceptions from attempting to write to the read-only replica since applying it. |
ca6377c
to
dc36922
Compare
Resetting failed attempts after sign in happened inside a warden hook specific for the lockable module, but that was hidden inside the hook implementation and didn't allow any user customization. One such customization needed for example is to direct these updates to a write DB when using a multi-DB setup. With the logic hidden in the warden hook this wasn't possible, now that it's exposed in a model method much like trackable, we can override the model method to wrap it in a connection switch block for example, point to a write DB, and simply call `super`. Closes #5310 Related to #5264 and #5133
dc36922
to
a3ae35e
Compare
Thanks @geoffharcourt @mhenrixon, this is now on master and will be on the next release, which I'm hoping to cut soon. |
Hey @carlosantoniodasilva Please could I ask when you're planning on the next release to RubyGems? I've just come across this as we're looking for a fix to this issue with Rails 6.1 multi-database switching. Many thanks! |
I just pushed v4.8 including this change, please give it a try and report back if you have any issues. Thanks. |
@carlosantoniodasilva Thanks so much, really appreciate it 🙌 |
Resetting failed attempts after sign in happened inside a warden hook
specific for the lockable module, but that was hidden inside the hook
implementation and didn't allow any user customization.
One such customization needed for example is to direct these updates to
a write DB when using a multi-DB setup. With the logic hidden in the
warden hook this wasn't possible, now that it's exposed in a model
method much like trackable, we can override the model method to wrap it
in a connection switch block for example, point to a write DB, and
simply call
super
.Closes #5310
Related to #5264 and #5133