Welcome to mirror list, hosted at ThFree Co, Russian Federation.

skips_already_signed_in_message.rb « concerns « controllers « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 7630cf4f4e1bbe2fbe66ba8832e73e2f094be84e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
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