当管理员和用户登录到同一页面时,在设备注销时遇到问题
例如,我在chrome浏览器中以用户身份登录,在同一浏览器中以管理员身份登录,当我注销管理会话时,用户会话将自动注销并重定向到登录页面。
当我尝试以用户身份登录时,它已成功登录,并转到管理员登录页面并尝试登录,它显示-
ActionController::InvalidAuthenticityToken发布于 2017-01-05 00:36:06
今天我也遇到了同样的问题。为了以防万一,我想分享我找到的一个解决方案。我在设备存储库中读到这个问题后产生了这个想法: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
# ...我不知道这是不是最好的解决方案。如果有人有其他的解决方案,我很乐意学习。
https://stackoverflow.com/questions/39725248
复制相似问题