[英]Rails_Admin Sign out not Redirecting (Devise)
我們在應用程序中使用Devise,Rails_Admin和Simple_Token_Authentication(用於API)。
除注銷外,一切正常。 當我們單擊“注銷”時,將發出以下請求,並且用戶將被注銷。
在2015-07-12 18:50:44 +0530由Devise :: SessionsController#destroy作為HTML參數處理時,開始以127.0.0.1的形式刪除“ / admins / sign_out”:HTML參數:{“ authenticity_token” =>“ rtSRPzpRN7cWEk8wV8q6VDAUB575ZV46JeFFlMFVOQc =”} (0.4毫秒)選擇“管理員”。*從“管理員”位置“管理員”。“ id” = 1 ORDER BY“管理員”。“ id” ASC LIMIT 1(0.1毫秒)開始事務處理(0.1毫秒)提交事務完成204 700毫秒內沒有內容(ActiveRecord:0.5毫秒)
問題在於頁面退出后不會重定向。
再次按下退出按鈕時,請求如下:
在2015-07-12 19:01:59 +0530由Devise :: SessionsController#destroy作為HTML參數處理時,開始以127.0.0.1的形式刪除“ / admins / sign_out”:{“ authenticity_token” =>“ dHuxA5hRosyquhlsRmchK3vW9bQOCM / YXYXUNMxTufc =”}篩選器鏈因:verify_signed_out_user呈現或重定向而停止。已完成204在1毫秒內沒有內容(ActiveRecord:0.0毫秒)
這是應用程序控制器(app / controllers / 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
這是app / config / initializers / rails_admin.rb中與設計相關的代碼
config.authenticate_with do
warden.authenticate! scope: :admin
end
config.current_user_method(&:current_admin)
請提出建議。 提前致謝!
問題出在after_sign_out_path_for(resource_or_scope)
。
request.referrer
重定向到當前頁面 。
相應地更改after_sign_out_path_for(resource_or_scope)
。 如果您想重定向到root_path
,那么下面的工作。
def after_sign_out_path_for(resource_or_scope)
root_path
end
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.