diff --git a/CHANGELOG.md b/CHANGELOG.md index 6752c4d..30d5ba7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,10 @@ # Changelog -## Unreleased +# Unreleased + +### Added + +- Add default flash notice for sign out (#178) ### Fixed diff --git a/app/controllers/passwordless/sessions_controller.rb b/app/controllers/passwordless/sessions_controller.rb index 32fe4cf..90bb08f 100644 --- a/app/controllers/passwordless/sessions_controller.rb +++ b/app/controllers/passwordless/sessions_controller.rb @@ -98,7 +98,12 @@ def confirm # @see ControllerHelpers#sign_out def destroy sign_out(authenticatable_class) - redirect_to(passwordless_sign_out_redirect_path, Passwordless.config.redirect_to_response_options.dup) + + redirect_to( + passwordless_sign_out_redirect_path, + notice: I18n.t("passwordless.sessions.destroy.signed_out"), + **redirect_to_options + ) end protected diff --git a/config/locales/en.yml b/config/locales/en.yml index 488813d..d813971 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -17,6 +17,8 @@ en: invalid_token: "Token is invalid" session_expired: "Your session has expired, please sign in again." token_claimed: "This link has already been used, try requesting the link again" + destroy: + signed_out: "Signed out successfully" mailer: sign_in: subject: "Signing in ✨" diff --git a/test/controllers/passwordless/sessions_controller_test.rb b/test/controllers/passwordless/sessions_controller_test.rb index 9fed75f..39d2efb 100644 --- a/test/controllers/passwordless/sessions_controller_test.rb +++ b/test/controllers/passwordless/sessions_controller_test.rb @@ -196,9 +196,17 @@ class << User assert_equal 200, status assert_equal "/", path + assert_match "Signed out successfully", flash[:notice] assert pwless_session(User).blank? end + test("DELETE /:passwordless_for/sign_out :: When response options are configured ") do + with_config(redirect_to_response_options: {notice: "my custom notice"}) do + get "/users/sign_out" + assert_match "my custom notice", flash[:notice] + end + end + class Helpers extend Passwordless::ControllerHelpers end