Got problem in devise logout while admin and user logged in same page
For example i logged as user in chrome browser and logged as admin in the same browser,when i logged out of admin session the user session is automatically logged out and redirect to sign in page.
When i try to login as user it's successfully logged in and goes to the admin login page and try to log-in it shows -
ActionController::InvalidAuthenticityToken
I had the same problem today. Just in case, I would like to share one solution I found. I got this idea after reading this issue in device repo: https://github.com/plataformatec/devise/issues/3461
class Identities::SessionsController < Devise::SessionsController
rescue_from ActionController::InvalidAuthenticityToken, with: :force_log_out
#...
def force_log_out
return unless params[:action] == 'destroy'
puts "rescued ActionController::InvalidAuthenticityToken"
puts "force log out and redirect back to '/'"
sign_out_all_scopes
redirect_to '/'
end
# ...
I do not know if this is the best solution. If anybody has other solutions, I would like to learn them.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.