<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>vendor/metaid-1.0/metaid.rb</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -108,7 +108,11 @@ class ApplicationController &lt; ActionController::Base
     end
     
     def retrieve_current_user
-      @current_user || authenticate_with_http_basic { |u, p| User.find_by_token(u) } || (session[:user_id] &amp;&amp; User.find_by_id(session[:user_id]))
+      RAILS_DEFAULT_LOGGER.warn &quot;COOKIE: #{cookies[:login_token].inspect}&quot;
+      @current_user || 
+        authenticate_with_http_basic { |u, p| User.find_by_token(u) } ||
+        (cookies[:login_token] &amp;&amp; User.find_by_id_and_token(*cookies[:login_token].split(&quot;;&quot;))) || 
+        (session[:user_id] &amp;&amp; User.find_by_id(session[:user_id]))
     end
     
     def retrieve_current_repository</diff>
      <filename>app/controllers/application.rb</filename>
    </modified>
    <modified>
      <diff>@@ -7,7 +7,7 @@ class HooksController &lt; ApplicationController
   end
   
   def create
-    @hook = current_repository.hooks.create!(:name =&gt; params[:name], :options =&gt; params[:hook])
+    @hook = current_repository.hooks.create(:name =&gt; params[:name], :options =&gt; params[:hook])
     respond_to do |format|
       format.js
     end
@@ -15,6 +15,7 @@ class HooksController &lt; ApplicationController
   
   def update
     @hook.options = params[:hook]
+    @hook.save
     respond_to do |format|
       format.js
     end</diff>
      <filename>app/controllers/hooks_controller.rb</filename>
    </modified>
    <modified>
      <diff>@@ -36,6 +36,9 @@ class InstallController &lt; ApplicationController
       @repository.save!
       @user.save!
     end
+    
+    cookies[:login_token] = {:value =&gt; &quot;#{@user.id};#{@user.token}&quot;, :expires =&gt; 1.year.from_now.utc, :domain =&gt; &quot;.#{Warehouse.domain}&quot;, :path =&gt; '/'}
+    
   rescue
     @message = $!.message
     logger.warn $!.message</diff>
      <filename>app/controllers/install_controller.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,4 +1,5 @@
 class RepositoriesController &lt; ApplicationController
+  skip_before_filter :check_for_repository
   before_filter :admin_required,            :only   =&gt; :create
   before_filter :repository_admin_required, :except =&gt; :create
   before_filter :find_or_initialize_repository</diff>
      <filename>app/controllers/repositories_controller.rb</filename>
    </modified>
    <modified>
      <diff>@@ -3,18 +3,18 @@ class SessionsController &lt; ApplicationController
 
   def create
     if using_open_id?
-      cookies['use_svn'] = {:value =&gt; '0', :expires =&gt; 1.year.ago.utc, :domain =&gt; Warehouse.domain, :path =&gt; '/'}
+      cookies['use_svn'] = {:value =&gt; '0', :expires =&gt; 1.year.ago.utc, :domain =&gt; &quot;.#{Warehouse.domain}&quot;, :path =&gt; '/'}
       authenticate_with_open_id do |result, identity_url|
         if result.successful? &amp;&amp; self.current_user = User.find_or_create_by_identity_url(identity_url)
-          redirect_to root_path
+          successful_login
         else
           status_message :error, result.message || &quot;Sorry, no user by that identity URL exists (#{identity_url})&quot;
         end
       end
     else
-      cookies['use_svn'] = {:value =&gt; '1', :expires =&gt; 1.year.from_now.utc, :domain =&gt; Warehouse.domain, :path =&gt; '/'}
+      cookies['use_svn'] = {:value =&gt; '1', :expires =&gt; 1.year.from_now.utc, :domain =&gt; &quot;.#{Warehouse.domain}&quot;, :path =&gt; '/'}
       if self.current_user = User.authenticate(params[:login], params[:password])
-        redirect_to root_path
+        successful_login
       else
         status_message :error, &quot;Invalid Password&quot;
       end
@@ -45,7 +45,7 @@ class SessionsController &lt; ApplicationController
     self.current_user = User.find_by_token(params[:token]) unless params[:token].blank?
     return if request.get? &amp;&amp; params[:open_id_complete].nil?
     if using_open_id?
-      cookies['use_svn'] = {:value =&gt; '0', :expires =&gt; 1.year.ago.utc, :domain =&gt; Warehouse.domain, :path =&gt; '/'}
+      cookies['use_svn'] = {:value =&gt; '0', :expires =&gt; 1.year.ago.utc, :domain =&gt; &quot;.#{Warehouse.domain}&quot;, :path =&gt; '/'}
       authenticate_with_open_id do |result, identity_url|
         if result.successful?
           current_user.identity_url = identity_url
@@ -54,11 +54,17 @@ class SessionsController &lt; ApplicationController
         end
       end
     else
-      cookies['use_svn'] = {:value =&gt; '1', :expires =&gt; 1.year.from_now.utc, :domain =&gt; Warehouse.domain, :path =&gt; '/'}
+      cookies['use_svn'] = {:value =&gt; '1', :expires =&gt; 1.year.from_now.utc, :domain =&gt; &quot;.#{Warehouse.domain}&quot;, :path =&gt; '/'}
     end
     unless performed? 
       current_user.reset_token!
       redirect_to root_path
     end
   end
+
+protected
+  def successful_login
+    cookies[:login_token] = {:value =&gt; &quot;#{current_user.id};#{current_user.token}&quot;, :expires =&gt; 1.year.from_now.utc, :domain =&gt; &quot;#{Warehouse.domain}&quot;, :path =&gt; '/'}
+    redirect_to root_path
+  end
 end</diff>
      <filename>app/controllers/sessions_controller.rb</filename>
    </modified>
    <modified>
      <diff>@@ -8,7 +8,7 @@ class Hook &lt; ActiveRecord::Base
   before_create :set_default_active_state
   
   def properties
-    @properties ||= Warehouse::Hooks[name].new(nil, self)
+    @properties ||= Warehouse::Hooks[name].new(self, nil)
   end
   
   def options</diff>
      <filename>app/models/hook.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,4 +1,4 @@
-if @hook.save
+if @hook.errors.empty?
   page.call &quot;location.reload&quot;
 else
   page.alert &quot;The hook options were invalid.  Replace this with a less obtrusive prompt&quot;</diff>
      <filename>app/views/hooks/update.js.rjs</filename>
    </modified>
    <modified>
      <diff>@@ -27,7 +27,7 @@ namespace :warehouse do
     require 'yaml'
     require 'config/initializers/svn'
     require 'lib/cache_key'
-    $LOAD_PATH &lt;&lt; 'vendor/ruby-sequel/lib'
+    $LOAD_PATH &lt;&lt; 'vendor/ruby-sequel/lib' &lt;&lt; 'vendor/metaid-1.0'
     require 'lib/warehouse/command'
     ENV['DB_CONFIG'] ||= &quot;config/database.yml&quot;
     raise &quot;No database config at #{ENV['DB_CONFIG'].inspect}&quot; unless File.exist?(ENV['DB_CONFIG'])</diff>
      <filename>lib/tasks/importer.rake</filename>
    </modified>
    <modified>
      <diff>@@ -81,7 +81,7 @@ module Warehouse
         f.write tmpl.join(&quot;\n&quot;)
       end
       
-      self.class.session(Warehouse.session_options) if domain_is_blank &amp;&amp; !attributes[:domain].blank?
+      ApplicationController.session(Warehouse.session_options) if domain_is_blank &amp;&amp; !attributes[:domain].blank?
     end
   end
 </diff>
      <filename>lib/warehouse.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,3 +1,4 @@
+require 'metaid'
 module Warehouse
   class Command
     class &lt;&lt; self</diff>
      <filename>lib/warehouse/command.rb</filename>
    </modified>
    <modified>
      <diff>@@ -11,7 +11,7 @@ module Warehouse
       end
 
       def self.properties
-        @properties ||= new
+        @properties ||= new(nil)
       end
       
       def active</diff>
      <filename>lib/warehouse/hooks/base.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>c2a2e01d9d1b5f3625c4da0a6fb6d70021362598</id>
    </parent>
  </parents>
  <author>
    <name>rick</name>
    <email>rick@8456e5f2-bb15-0410-bd20-b44782a1fb1e</email>
  </author>
  <url>http://github.com/entp/warehouse/commit/40a8667bca372bcbb034cce17fe2dc32638bc4dd</url>
  <id>40a8667bca372bcbb034cce17fe2dc32638bc4dd</id>
  <committed-date>2007-10-09T11:22:54-07:00</committed-date>
  <authored-date>2007-10-09T11:22:54-07:00</authored-date>
  <message>tweak hooks and streamline installer process

git-svn-id: http://activereload.svn.engineyard.com/warehouse/trunk@2203 8456e5f2-bb15-0410-bd20-b44782a1fb1e</message>
  <tree>f188be1487254662512288ce7c741107fc0cf65e</tree>
  <committer>
    <name>rick</name>
    <email>rick@8456e5f2-bb15-0410-bd20-b44782a1fb1e</email>
  </committer>
</commit>
