about summary refs log tree commit diff
path: root/app/controllers/auth
diff options
context:
space:
mode:
authorThibG <thib@sitedethib.com>2020-05-10 10:16:39 +0200
committerGitHub <noreply@github.com>2020-05-10 10:16:39 +0200
commit45202f79ef45f0d141b1e2911b4fa34950777cad (patch)
treeb28095f2fc089c6379526027166cf30cce769a08 /app/controllers/auth
parenta4240fd0272eb79b7d99cccfa7d14e8a1e12921d (diff)
Remove confusing “You are already signed in.” flash message (#13547)
When attempting to access the log-in page while already logged in,
Devise's `require_no_authentication` kicks in and sets a flash
message “You are already signed in.”

In almost all cases, this also causes a redirect to /web, which
does not display or clear flash messages, thus leaving the message
to a potentially much later date, like for instance, accessing
/preferences several minutes after being redirected to /web.
Diffstat (limited to 'app/controllers/auth')
-rw-r--r--app/controllers/auth/sessions_controller.rb7
1 files changed, 7 insertions, 0 deletions
diff --git a/app/controllers/auth/sessions_controller.rb b/app/controllers/auth/sessions_controller.rb
index f48b17c79..e95909447 100644
--- a/app/controllers/auth/sessions_controller.rb
+++ b/app/controllers/auth/sessions_controller.rb
@@ -111,6 +111,13 @@ class Auth::SessionsController < Devise::SessionsController
     render :two_factor
   end
 
+  def require_no_authentication
+    super
+    # Delete flash message that isn't entirely useful and may be confusing in
+    # most cases because /web doesn't display/clear flash messages.
+    flash.delete(:alert) if flash[:alert] == I18n.t('devise.failure.already_authenticated')
+  end
+
   private
 
   def set_instance_presenter