2012-04-24 2 views
1

앱에 Basecamp 스타일의 하위 도메인을 사용하고 있습니다. 나는 사용자가 User.rb에서 다음을 사용하여 그들의 하위 도메인에 대한 액세스를 허용하고, 유증 사용 :개발자, 하위 도메인 및 수퍼 유저

def self.find_for_authentication(conditions={}) 
    conditions[:account_id] = Account.find_by_subdomain(conditions.delete(:subdomain)).id 
    super(conditions) 
    end 

이 확실 로그인을 시도하는 사용자와 관련된 계정이 하위 도메인을 일치하는지 확인하기 위해 검사합니다. 그것은 잘 작동합니다.

저의 문제는 수퍼 유저가 로그인 할 수 있도록 허용하고 싶습니다. 관련 '계정'이없는 사람입니다. 그들은 대신 사용자와 동일한에 부울 열 '는 "수퍼 유저가됩니다'모델.

가 거기에 올바른 하위 도메인 또는 확인 할 수있는 방법 '슈퍼 유저'상태를?

감사합니다!

답변

0

모든 수퍼 유저를 대상으로 계정을 만든 경우 어떻게해야합니까? 인증 프로세스의 어떤 단계가 호출 될지 모르지만이 행을 따라 무언가가 표시 될 수 있습니다 ..?

def self.find_for_authentication(conditions={}) 
    if subdomain = conditions.delete(:subdomain) 
    conditions[:account_id] = Account.find_by_subdomain(subdomain).id 
    elsif User.where(conditions).where(:superuser => true).length > 0 
    conditions[:account_id] = 1 # 1 is account reserved for super users 
    end 

    super(conditions) 
en