orky
orky

Reputation: 241

Rails/Devise: Force sign out & redirect on all pages when user session destroyed

I have a persistent error that keeps on popping up. Here's the use case:

  1. User is logged in & has multiple tabs/windows of the app open.
  2. User logs out (session is successfully destroyed) & is redirected back to home page (root_path).
  3. User reloads or takes action on any of the other already open tabs.
  4. User encounters error and must manually navigate to root_path via address bar.

Is there a best practice to prevent this altogether? Is it better to have an error page that has a link to the root path where they can log back in?

I appreciate any help at all. Thanks!

Upvotes: 1

Views: 993

Answers (1)

Mark
Mark

Reputation: 6404

According to the documentation if a user is not authenticatable you can redirect to a specific page.

https://github.com/plataformatec/devise/wiki/How-To:-Redirect-to-a-specific-page-when-the-user-can-not-be-authenticated

Maybe it is also helpful :

Redirect to log in page if user is not authenticated with Devise

Upvotes: 2

Related Questions