2011-07-15 63 views
0

我在使用authlogic單訪問令牌訪問頁面時出現問題,當超時退出設置爲true並設置了超時時間。Rails 3單訪問令牌和超時退出的Authlogic問題

user.rb:

acts_as_authentic do |c| 
    c.logged_in_timeout = 15.minutes 
end 

user_session.rb:

logout_on_timeout true 

控制器:

def single_access_allowed? 
    ["download_xml"].include?(action_name) 
end 

如果我嘗試使用令牌來訪問一個頁面/方法,它直接重定向遠離我的登錄頁面。打開超時時註銷超時。

如果我刪除超時代碼,並且在user.rb中只有acts_as_authentic,則單個訪問令牌可以工作。

我想能夠使用單個訪問令牌,所以另一個應用程序可以從我的Ruby on Rails網站打開一個XML文件。

任何想法,我可能做錯了什麼,以及在哪裏尋找修復它,並使其工作?

使用authlogic 3.0.3和rails 3.0.7。

+0

我還沒有帶想通這一個,如果任何人有任何想法? – Daniel

+0

發現這是在github上的authlogic一個開放的問題 - > https://github.com/binarylogic/authlogic/issues/64 mhaley說: 「如果你只是想解決您應用中的問題,你可以修改您的 UserSession模型,如下所示:「 class UserSession :single_access? after_persisting:enforce_timeout,:unless =>:single_access? 結束 但是,單個訪問令牌可以正常工作,但在超時時註銷將停止工作。 – Daniel

回答

0

這從https://github.com/binarylogic/authlogic/issues/64去年9月27日jgdreyes回答爲我工作:

我繼續和擴展Authlogic的陳舊?方法,以便它確實 不會將請求視爲陳舊?如果通過single_access訪問?這使邏輯logout_on_timeout保持原樣。

class UserSession < Authlogic::Session::Base logout_on_timeout true 
    def stale? 
    return false if single_access? 
    super 
    end 
end