2009-10-14 48 views
1

我開始使用comatose來處理我網站上的內容,但在使用我的現有身份驗證時使用通用的Authlogic配置時遇到了問題。昏迷與authlogic工作

在自述文件中,他介紹了使用Restful Authentication進行配置的示例,我想知道如何在一般的Authlogic設置中執行相同的操作?

#environment.rb 
    Comatose.configure do |config| 
     # Includes AuthenticationSystem in the ComatoseController 
     config.includes << :authenticated_system 
    end 

http://github.com/darthapo/comatose

+0

我想如果它可以繼承applcationcontoller但似乎無法得到它 要做到這一點。 – holden 2009-10-14 13:02:20

+0

那麼...我發現了一個很好的小工作,但我更喜歡如果他們是另一種方式...該插件直接從ActionController :: Base繼承,我將其更改爲ApplicationController,現在它的工作原理。但我更喜歡在我的應用程序內部執行某種操作,而不是在插件中進行更改。 ;-( 有任何想法嗎? – holden 2009-10-14 13:08:29

回答

0

我認爲更好的方式來做到這一點是從移動AUTH方法,到模塊,以及包括來自兩個的ApplicationController和昏迷。例如:

把你的AUTH方法,到user_sessions_helper:

module UserSessionsHelper 
    module AuthMethods 
    private 
     ... 
    def require_user 
     ... 

然後在您的ApplicationController模塊:

class ApplicationController < ActionController::Base 
    include UserSessionsHelper::AuthMethods 
    ... 

終於在昏迷的配置以及(environment.rb中):

Comatose.configure do |config| 
    config.admin_includes << "UserSessionsHelper::AuthMethods" 
    config.admin_authorization = :require_user 
end