You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add an option 'use_redirect_back_or_to_by_rails' to avoid definition conflicts
Fix: #296
Rails 7 released a new method called `redirect_back_or_to` as a replacement for `redirect_back`.
That may conflicts with the method by the same name defined by Sorcery.
This commit adds an option to set whether to use `redirect_back_or_to` defined by Rails 7, and
the method `redirect_to_before_login_path` as an alternative to sorcery's `redirect_back_or_to.
ref: rails/rails#40671
Copy file name to clipboardExpand all lines: lib/sorcery/controller.rb
+10-1Lines changed: 10 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -96,7 +96,16 @@ def current_user=(user)
96
96
97
97
# used when a user tries to access a page while logged out, is asked to login,
98
98
# and we want to return him back to the page he originally wanted.
99
-
defredirect_back_or_to(url,flash_hash={})
99
+
defredirect_back_or_to(...)
100
+
ifConfig.use_redirect_back_or_to_by_rails
101
+
super
102
+
else
103
+
warn('[WARNING] `redirect_back_or_to` overrides the method of the same name defined in Rails 7. If you want to avoid overriding, you can set `config.use_redirect_back_or_to_by_rails = true` and use `redirect_to_before_login_path`.')
0 commit comments