diff options
Diffstat (limited to 'app/controllers/concerns/skips_already_signed_in_message.rb')
-rw-r--r-- | app/controllers/concerns/skips_already_signed_in_message.rb | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/app/controllers/concerns/skips_already_signed_in_message.rb b/app/controllers/concerns/skips_already_signed_in_message.rb new file mode 100644 index 00000000000..7630cf4f4e1 --- /dev/null +++ b/app/controllers/concerns/skips_already_signed_in_message.rb @@ -0,0 +1,24 @@ +# frozen_string_literal: true + +# This concern can be included in devise controllers to skip showing an "already signed in" +# warning on registrations and logins +module SkipsAlreadySignedInMessage + extend ActiveSupport::Concern + + included do + # replaced with :require_no_authentication_without_flash + # rubocop: disable Rails/LexicallyScopedActionFilter + # The actions are defined in Devise + skip_before_action :require_no_authentication, only: [:new, :create] + before_action :require_no_authentication_without_flash, only: [:new, :create] + # rubocop: enable Rails/LexicallyScopedActionFilter + end + + def require_no_authentication_without_flash + require_no_authentication + + return unless flash[:alert] == I18n.t('devise.failure.already_authenticated') + + flash[:alert] = nil + end +end |