Skip to content

Commit

Permalink
Add an option rename_redirect_back_or_to
Browse files Browse the repository at this point in the history
Fix Sorcery#296

`redirect_back_or_to` defined by Rails 7 conflict by name with Sorcery's 'redirect_back_or_to'.
This commit adds an option to rename this method to 'redirect_to_before_login_path'.

ref: Sorcery#296 (comment)
  • Loading branch information
atolix committed Apr 10, 2024
1 parent bbebb0f commit f43b1b5
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
9 changes: 9 additions & 0 deletions lib/generators/sorcery/templates/initializer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,15 @@
#
# config.save_return_to_url =

# Set whether to rename 'redirect_back_or_to' to 'redirect_to_before_login_path'.
# Rails 7 released a new method called 'redirect_back_or_to' as a replacement for 'redirect_back'.
# That may conflict with the method by the same name defined by Sorcery.
# If you set this option to true, Sorcery define a method called 'redirect_to_before_login_path'
# in place of the soft-deprecated 'redirect_back_or_to'.
# Default: `false`
#
# config.rename_redirect_back_or_to =

# Set domain option for cookies; Useful for remember_me submodule.
# Default: `nil`
#
Expand Down
6 changes: 5 additions & 1 deletion lib/sorcery/controller/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ class << self
attr_accessor :after_logout
attr_accessor :after_remember_me

# set whether to rename 'redirect_back_or_to' to 'redirect_to_before_login_path'.
attr_accessor :rename_redirect_back_or_to

def init!
@defaults = {
:@user_class => nil,
Expand All @@ -32,7 +35,8 @@ def init!
:@after_logout => Set.new,
:@after_remember_me => Set.new,
:@save_return_to_url => true,
:@cookie_domain => nil
:@cookie_domain => nil,
:@rename_redirect_back_or_to => false
}
end

Expand Down

0 comments on commit f43b1b5

Please sign in to comment.