Skip to content
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

Only call reset_session when it's defined #124

Merged
merged 3 commits into from
Aug 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## Unreleased

### Fixed

- Fix `Passwordless#ControllerHelpers` to be used outside controllers (#124)

## 0.11.0

### Changed
Expand Down
4 changes: 2 additions & 2 deletions lib/passwordless/controller_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def sign_in(record)
raise Passwordless::Errors::SessionTimedOutError if passwordless_session.timed_out?

old_session = session.dup.to_hash
reset_session
reset_session if defined?(reset_session) # allow usage outside controllers
old_session.each_pair { |k, v| session[k.to_sym] = v }

key = session_key(passwordless_session.authenticatable_type)
Expand All @@ -113,7 +113,7 @@ def sign_out(authenticatable_class)
cookies.delete(key)

# /deprecated
reset_session
reset_session if defined?(reset_session) # allow usage outside controllers
true
end

Expand Down
3 changes: 0 additions & 3 deletions test/dummy/config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@

module Dummy
class Application < Rails::Application
# Initialize configuration defaults for originally generated Rails version.
config.load_defaults 7.0

# Configuration for the application, engines, and railties goes here.
#
# These settings can be overridden in specific environments using the files
Expand Down