def http_basic_authentication if request.format == Mime::XML authenticate_or_request_with_http_basic do |username, api_key| self.current_user = User.find(:first, :from => 'users, accounts', :conditions => ["accounts.id = users.account_id AND accounts.api_key = ?", api_key]) end end end self.current_user = Account.find_by_api_key(api_key).user