我們在應用程序中使用Devise,Rails_Admin和Simple_Token_Authentication(用於API)。Rails_Admin退出不重定向(設計)
一切都工作正常,除了退出。當我們點擊退出時,會發出以下請求並且用戶退出登錄。
發起者DELETE 「/管理員/ SIGN_OUT」 爲127.0.0.1在2015年7月12日18時50分44秒 0530處理由設計:: SessionsController#破壞爲HTML參數: { 「authenticity_token」= >「rtSRPzpRN7cWEk8wV8q6VDAUB575ZV46JeFFlMFVOQc =」} 管理負載(0.4ms)SELECT「admins」。* FROM「admins」WHERE 「admins」。「id」= 1 ORDER BY「admins」。「id」ASC LIMIT 1(0.1ms) 開始交易(0.1毫秒)提交的事務已完成204沒有 內容在700毫秒(ActiveRecord的:爲0.5ms)
問題該頁面在退出後不會重定向。
再次按下退出按鈕,這裏是要求:
開始刪除「/管理員/ SIGN_OUT」爲127.0.0.1,在2015年7月12日19時01分59秒 0530處理通過設計:: SessionsController#破壞爲HTML參數: { 「authenticity_token」=> 「dHuxA5hRosyquhlsRmchK3vW9bQOCM/YXYXUNMxTufc =」} 過濾器鏈停止爲:verify_signed_out_user呈現或重定向 完成204在1ms內無內容(ActiveRecord的:0.0ms)
這裏是應用控制器(應用程序/控制器/ application_controller.rb):
class ApplicationController < ActionController::Base
protect_from_forgery
skip_before_filter :verify_signed_out_user
respond_to :html, :json
protected
# Overwriting the sign_out redirect path method
def after_sign_out_path_for(resource_or_scope)
request.referrer
end
end
以下是在應用程序/配置/初始化/ rails_admin.rb的色器件相關的代碼
config.authenticate_with do
warden.authenticate! scope: :admin
end
config.current_user_method(&:current_admin)
請提出。提前致謝!
不知道這是否會工作或沒有,但你能試着做一個自定義的'SessionsController <制定:: SessionsController'繼承設計控制器和路線文件中添加這和添加'skip_before_filter:verify_signed_out_user,只有:摧毀'那裏。 – Deep
嗨深。已經嘗試過..沒有工作。 –
還有一個方法寫在這個鏈接上'Devise :: Controllers :: Helpers#stored_location_for' https://github.com/plataformatec/devise/wiki/How-To:-Change-the-redirect-path -after-destructioning-a-session-ie-sign-out可能對你有幫助 – Deep