Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow wrapping of lockable Warden after sign-in hook
For applications using a primary/replica multiple database setup, Rails 6's default connection switching can lead to the `Lockable` after sign-in hook firing on `GET` requests, getting the read-only database, and then attempting to write while zeroing out the user's failed attempts. This change adds a customizable wrapper proc that can allow applications to customize this behavior. For a primary/replica setup using ActiveRecord's default connection switching, it might look like this: ```ruby class ConnectionWrapper def process(&block) # Use the writable DB connection no matter what ApplicationRecord.connected_to(role: :writing) do block.call end end end Devise.setup do |config| config.warden_hook_save_wrapper = ConnectionWrapper.new end ``` Fix heartcombo#5264
- Loading branch information