<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>db/migrate/20080924120254_add_identity_url_to_user.rb</filename>
    </added>
    <added>
      <filename>db/migrate/20080924123512_add_open_id_authentication_tables.rb</filename>
    </added>
    <added>
      <filename>vendor/plugins/open_id_authentication/CHANGELOG</filename>
    </added>
    <added>
      <filename>vendor/plugins/open_id_authentication/README</filename>
    </added>
    <added>
      <filename>vendor/plugins/open_id_authentication/Rakefile</filename>
    </added>
    <added>
      <filename>vendor/plugins/open_id_authentication/generators/open_id_authentication_tables/open_id_authentication_tables_generator.rb</filename>
    </added>
    <added>
      <filename>vendor/plugins/open_id_authentication/generators/open_id_authentication_tables/templates/migration.rb</filename>
    </added>
    <added>
      <filename>vendor/plugins/open_id_authentication/generators/upgrade_open_id_authentication_tables/templates/migration.rb</filename>
    </added>
    <added>
      <filename>vendor/plugins/open_id_authentication/generators/upgrade_open_id_authentication_tables/upgrade_open_id_authentication_tables_generator.rb</filename>
    </added>
    <added>
      <filename>vendor/plugins/open_id_authentication/init.rb</filename>
    </added>
    <added>
      <filename>vendor/plugins/open_id_authentication/lib/open_id_authentication.rb</filename>
    </added>
    <added>
      <filename>vendor/plugins/open_id_authentication/lib/open_id_authentication/association.rb</filename>
    </added>
    <added>
      <filename>vendor/plugins/open_id_authentication/lib/open_id_authentication/db_store.rb</filename>
    </added>
    <added>
      <filename>vendor/plugins/open_id_authentication/lib/open_id_authentication/mem_cache_store.rb</filename>
    </added>
    <added>
      <filename>vendor/plugins/open_id_authentication/lib/open_id_authentication/nonce.rb</filename>
    </added>
    <added>
      <filename>vendor/plugins/open_id_authentication/lib/open_id_authentication/request.rb</filename>
    </added>
    <added>
      <filename>vendor/plugins/open_id_authentication/lib/open_id_authentication/timeout_fixes.rb</filename>
    </added>
    <added>
      <filename>vendor/plugins/open_id_authentication/tasks/open_id_authentication_tasks.rake</filename>
    </added>
    <added>
      <filename>vendor/plugins/open_id_authentication/test/mem_cache_store_test.rb</filename>
    </added>
    <added>
      <filename>vendor/plugins/open_id_authentication/test/normalize_test.rb</filename>
    </added>
    <added>
      <filename>vendor/plugins/open_id_authentication/test/open_id_authentication_test.rb</filename>
    </added>
    <added>
      <filename>vendor/plugins/open_id_authentication/test/status_test.rb</filename>
    </added>
    <added>
      <filename>vendor/plugins/open_id_authentication/test/test_helper.rb</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -1,22 +1,26 @@
 class UsersController &lt; ApplicationController
+  skip_before_filter :verify_authenticity_token, :only =&gt; :create
+  
   def new
     @user = User.new
   end
  
   def create
     logout_keeping_session!
-    @user = User.new(params[:user])
-    @user.register! if @user &amp;&amp; @user.valid?
-    success = @user &amp;&amp; @user.valid?
-    if success &amp;&amp; @user.errors.empty?
-      redirect_back_or_default('/')
-      flash[:notice] = &quot;Thanks for signing up!  We're sending you an email with your activation code.&quot;
+    if using_open_id?
+      authenticate_with_open_id(params[:openid_url], :return_to =&gt; open_id_create_url, 
+        :required =&gt; [ :nickname, :email ]) do |result, identity_url, registration|
+        if result.successful?
+          create_new_user(:identity_url =&gt; identity_url, :login =&gt; registration['nickname'], :email =&gt; registration['email'])
+        else
+          failed_creation(result.message || &quot;Sorry, something went wrong&quot;)
+        end
+      end
     else
-      flash[:error]  = &quot;We couldn't set up that account, sorry.  Please try again, or contact an admin (link is above).&quot;
-      render :action =&gt; 'new'
+      create_new_user(params[:user])
     end
   end
-
+  
   def activate
     logout_keeping_session!
     user = User.find_by_activation_code(params[:activation_code]) unless params[:activation_code].blank?
@@ -33,4 +37,26 @@ class UsersController &lt; ApplicationController
       redirect_back_or_default('/')
     end
   end
+  
+  protected
+  
+  def create_new_user(attributes)
+    @user = User.new(attributes)
+    @user.register! if @user &amp;&amp; @user.valid?
+    if @user.errors.empty?
+      successful_creation
+    else
+      failed_creation
+    end
+  end
+  
+  def successful_creation
+    redirect_back_or_default('/')
+    flash[:notice] = &quot;Thanks for signing up!  We're sending you an email with your activation code.&quot;
+  end
+  
+  def failed_creation(message = 'Sorry, there was an error creating your account')
+    flash[:error] = message
+    render :action =&gt; :new
+  end
 end</diff>
      <filename>app/controllers/users_controller.rb</filename>
    </modified>
    <modified>
      <diff>@@ -7,16 +7,18 @@ class User &lt; ActiveRecord::Base
   include Authorization::AasmRoles
 
   # Validations
-  validates_presence_of :login
-  validates_length_of :login, :within =&gt; 3..40
-  validates_uniqueness_of :login, :case_sensitive =&gt; false
-  validates_format_of :login, :with =&gt; RE_LOGIN_OK, :message =&gt; MSG_LOGIN_BAD
+  validates_presence_of :login, :if =&gt; :not_using_openid?
+  validates_length_of :login, :within =&gt; 3..40, :if =&gt; :not_using_openid?
+  validates_uniqueness_of :login, :case_sensitive =&gt; false, :if =&gt; :not_using_openid?
+  validates_format_of :login, :with =&gt; RE_LOGIN_OK, :message =&gt; MSG_LOGIN_BAD, :if =&gt; :not_using_openid?
   validates_format_of :name, :with =&gt; RE_NAME_OK, :message =&gt; MSG_NAME_BAD, :allow_nil =&gt; true
   validates_length_of :name, :maximum =&gt; 100
-  validates_presence_of :email
-  validates_length_of :email, :within =&gt; 6..100 #r@a.wk
-  validates_uniqueness_of :email, :case_sensitive =&gt; false
-  validates_format_of :email, :with =&gt; RE_EMAIL_OK, :message =&gt; MSG_EMAIL_BAD
+  validates_presence_of :email, :if =&gt; :not_using_openid?
+  validates_length_of :email, :within =&gt; 6..100, :if =&gt; :not_using_openid?
+  validates_uniqueness_of :email, :case_sensitive =&gt; false, :if =&gt; :not_using_openid?
+  validates_format_of :email, :with =&gt; RE_EMAIL_OK, :message =&gt; MSG_EMAIL_BAD, :if =&gt; :not_using_openid?
+  validates_uniqueness_of :identity_url, :unless =&gt; :not_using_openid?
+  validate :normalize_identity_url
   
   # Relationships
   has_and_belongs_to_many :roles
@@ -24,14 +26,9 @@ class User &lt; ActiveRecord::Base
   # HACK HACK HACK -- how to do attr_accessible from here?
   # prevents a user from submitting a crafted form that bypasses activation
   # anything else you want your user to change should be added here.
-  attr_accessible :login, :email, :name, :password, :password_confirmation
+  attr_accessible :login, :email, :name, :password, :password_confirmation, :identity_url
 
   # Authenticates a user by their login name and unencrypted password.  Returns the user or nil.
-  #
-  # uff.  this is really an authorization, not authentication routine.  
-  # We really need a Dispatch Chain here or something.
-  # This will also let us return a human error message.
-  #
   def self.authenticate(login, password)
     u = find_in_state :first, :active, :conditions =&gt; { :login =&gt; login } # need to get the salt
     u &amp;&amp; u.authenticated?(password) ? u : nil
@@ -42,6 +39,16 @@ class User &lt; ActiveRecord::Base
     list ||= self.roles.map(&amp;:name)
     list.include?(role.to_s) || list.include?('admin')
   end
+  
+  # Not using open id
+  def not_using_openid?
+    identity_url.blank?
+  end
+  
+  # Overwrite password_required for open id
+  def password_required?
+    new_record? ? not_using_openid? &amp;&amp; (crypted_password.blank? || !password.blank?) : !password.blank?
+  end
 
   protected
     
@@ -49,4 +56,10 @@ class User &lt; ActiveRecord::Base
     self.deleted_at = nil
     self.activation_code = self.class.make_token
   end
+  
+  def normalize_identity_url
+    self.identity_url = OpenIdAuthentication.normalize_url(identity_url) unless not_using_openid?
+  rescue URI::InvalidURIError
+    errors.add_to_base(&quot;Invalid OpenID URL&quot;)
+  end
 end</diff>
      <filename>app/models/user.rb</filename>
    </modified>
    <modified>
      <diff>@@ -23,6 +23,15 @@
 			&lt;/li&gt;
 		&lt;/ol&gt;
 	&lt;/fieldset&gt;
+	&lt;fieldset&gt;
+		&lt;legend&gt;Signup with OpenID&lt;/legend&gt;
+		&lt;ol&gt;
+			&lt;li&gt;
+				&lt;label for=&quot;openid_url&quot;&gt;OpenID URL&lt;/label&gt;
+				&lt;%= text_field_tag :openid_url, params[:openid_url] || params['openid.identity'] %&gt;
+			&lt;/li&gt;
+		&lt;/ol&gt;
+	&lt;/fieldset&gt;
 	&lt;div class=&quot;buttons&quot;&gt;
 		&lt;%= submit_tag 'Sign up' %&gt;
 	&lt;/div&gt;</diff>
      <filename>app/views/users/new.html.erb</filename>
    </modified>
    <modified>
      <diff>@@ -7,6 +7,8 @@ ActionController::Routing::Routes.draw do |map|
   map.activate '/activate/:activation_code', :controller =&gt; 'users', :action =&gt; 'activate', :activation_code =&gt; nil
   map.forgot_password '/forgot_password', :controller =&gt; 'passwords', :action =&gt; 'new'
   map.change_password '/change_password/:reset_code', :controller =&gt; 'passwords', :action =&gt; 'reset'
+  map.open_id_complete '/opensession', :controller =&gt; &quot;sessions&quot;, :action =&gt; &quot;create&quot;, :requirements =&gt; { :method =&gt; :get }
+  map.open_id_create '/opencreate', :controller =&gt; &quot;users&quot;, :action =&gt; &quot;create&quot;, :requirements =&gt; { :method =&gt; :get }
   
   # Restful Authentication Resources
   map.resources :users</diff>
      <filename>config/routes.rb</filename>
    </modified>
    <modified>
      <diff>@@ -9,7 +9,22 @@
 #
 # It's strongly recommended to check this file into your version control system.
 
-ActiveRecord::Schema.define(:version =&gt; 20080912160936) do
+ActiveRecord::Schema.define(:version =&gt; 20080924123512) do
+
+  create_table &quot;open_id_authentication_associations&quot;, :force =&gt; true do |t|
+    t.integer &quot;issued&quot;
+    t.integer &quot;lifetime&quot;
+    t.string  &quot;handle&quot;
+    t.string  &quot;assoc_type&quot;
+    t.binary  &quot;server_url&quot;
+    t.binary  &quot;secret&quot;
+  end
+
+  create_table &quot;open_id_authentication_nonces&quot;, :force =&gt; true do |t|
+    t.integer &quot;timestamp&quot;,  :null =&gt; false
+    t.string  &quot;server_url&quot;
+    t.string  &quot;salt&quot;,       :null =&gt; false
+  end
 
   create_table &quot;passwords&quot;, :force =&gt; true do |t|
     t.integer  &quot;user_id&quot;
@@ -35,8 +50,8 @@ ActiveRecord::Schema.define(:version =&gt; 20080912160936) do
     t.datetime &quot;updated_at&quot;
   end
 
-  add_index &quot;sessions&quot;, [&quot;updated_at&quot;], :name =&gt; &quot;index_sessions_on_updated_at&quot;
   add_index &quot;sessions&quot;, [&quot;session_id&quot;], :name =&gt; &quot;index_sessions_on_session_id&quot;
+  add_index &quot;sessions&quot;, [&quot;updated_at&quot;], :name =&gt; &quot;index_sessions_on_updated_at&quot;
 
   create_table &quot;users&quot;, :force =&gt; true do |t|
     t.string   &quot;login&quot;,                     :limit =&gt; 40
@@ -52,6 +67,7 @@ ActiveRecord::Schema.define(:version =&gt; 20080912160936) do
     t.datetime &quot;deleted_at&quot;
     t.datetime &quot;created_at&quot;
     t.datetime &quot;updated_at&quot;
+    t.string   &quot;identity_url&quot;
   end
 
   add_index &quot;users&quot;, [&quot;login&quot;], :name =&gt; &quot;index_users_on_login&quot;, :unique =&gt; true</diff>
      <filename>db/schema.rb</filename>
    </modified>
    <modified>
      <diff>@@ -12,13 +12,13 @@ module Authorization
         aasm_column :state
         aasm_initial_state :initial =&gt; :pending
         aasm_state :passive
-        aasm_state :pending, :enter =&gt; :make_activation_code
+        aasm_state :pending, :enter =&gt; :make_activation_code, 
         aasm_state :active,  :enter =&gt; :do_activate
         aasm_state :suspended
         aasm_state :deleted, :enter =&gt; :do_delete
 
         aasm_event :register do
-          transitions :from =&gt; :passive, :to =&gt; :pending, :guard =&gt; Proc.new {|u| !(u.crypted_password.blank? &amp;&amp; u.password.blank?) }
+          transitions :from =&gt; :passive, :to =&gt; :pending, :guard =&gt; Proc.new {|u| !(u.crypted_password.blank? &amp;&amp; u.password.blank?) || !u.not_using_openid? }
         end
         
         aasm_event :activate do</diff>
      <filename>vendor/plugins/restful_authentication/lib/authorization/aasm_roles.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>0bf2d9fb9ff51a1ca0d3e43f972e5788e6bc17c2</id>
    </parent>
  </parents>
  <author>
    <name>Jim Neath</name>
    <email>jim@virtuaffinity.net</email>
  </author>
  <url>http://github.com/laktek/extended-bort/commit/0298a4ab788a20dbb73d40ac32d5c907a5a21030</url>
  <id>0298a4ab788a20dbb73d40ac32d5c907a5a21030</id>
  <committed-date>2008-09-24T06:37:30-07:00</committed-date>
  <authored-date>2008-09-24T06:37:30-07:00</authored-date>
  <message>Started work on OpenID integration</message>
  <tree>539399c2d4231c75d3586c263e7139d3eff3f013</tree>
  <committer>
    <name>Jim Neath</name>
    <email>jim@virtuaffinity.net</email>
  </committer>
</commit>
