<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -71,6 +71,8 @@ module AuthlogicOpenid
       # if their OpenID provider supports it.
       def save(perform_validation = true, &amp;block)
         return false if perform_validation &amp;&amp; block_given? &amp;&amp; authenticate_with_openid? &amp;&amp; !authenticate_with_openid
+        
+        return false if new_record? &amp;&amp; !openid_complete?
         result = super
         yield(result) if block_given?
         result
@@ -90,7 +92,7 @@ module AuthlogicOpenid
           options = {}
           options[:required] = self.class.openid_required_fields
           options[:optional] = self.class.openid_optional_fields
-          options[:return_to] = session_class.controller.url_for(:for_model =&gt; &quot;1&quot;)
+          options[:return_to] = session_class.controller.url_for(:for_model =&gt; &quot;1&quot;,:controller=&gt;&quot;users&quot;,:action=&gt;&quot;create&quot;)
           
           session_class.controller.send(:authenticate_with_open_id, openid_identifier, options) do |result, openid_identifier, registration|
             if result.unsuccessful?
@@ -102,7 +104,6 @@ module AuthlogicOpenid
             
             return true
           end
-          
           return false
         end
         
@@ -112,9 +113,13 @@ module AuthlogicOpenid
         # Basically you will get a hash of values passed as a single argument. Then just map them as you see fit. Check out
         # the source of this method for an example.
         def map_openid_registration(registration) # :doc:
-          self.name ||= registration[:fullname] if respond_to?(:name) &amp;&amp; !registration[:fullname].blank?
-          self.first_name ||= registration[:fullname].split(&quot; &quot;).first if respond_to?(:first_name) &amp;&amp; !registration[:fullname].blank?
-          self.last_name ||= registration[:fullname].split(&quot; &quot;).last if respond_to?(:last_name) &amp;&amp; !registration[:last_name].blank?
+          registration.symbolize_keys!
+          [self.class.openid_required_fields+self.class.openid_optional_fields].flatten.each do |field|
+            setter=&quot;#{field.to_s}=&quot;.to_sym
+            if respond_to?(setter)
+              send setter,registration[field]
+            end
+          end
         end
         
         # This method works in conjunction with map_saved_attributes.</diff>
      <filename>lib/authlogic_openid/acts_as_authentic.rb</filename>
    </modified>
    <modified>
      <diff>@@ -28,6 +28,17 @@ module AuthlogicOpenid
         rw_config(:find_by_openid_identifier_method, value, :find_by_openid_identifier)
       end
       alias_method :find_by_openid_identifier_method=, :find_by_openid_identifier_method
+      
+      # Add this in your Session object to Auto Register a new user using openid via sreg
+      def auto_register(value=true)
+        auto_register_value(value)
+      end
+      
+      def auto_register_value(value=nil)
+        rw_config(:auto_register,value,false)
+      end
+      
+      alias_method :auto_register=,:auto_register
     end
     
     module Methods
@@ -70,21 +81,39 @@ module AuthlogicOpenid
         def find_by_openid_identifier_method
           self.class.find_by_openid_identifier_method
         end
+
+        def find_by_openid_identifier_method
+          self.class.find_by_openid_identifier_method
+        end
+        
+        def auto_register?
+          self.class.auto_register_value
+        end
         
         def validate_by_openid
           self.remember_me = controller.params[:remember_me] == &quot;true&quot; if controller.params.key?(:remember_me)
+          self.attempted_record = klass.send(find_by_openid_identifier_method, openid_identifier)
+          if !attempted_record
+            if auto_register?
+              self.attempted_record = klass.new :openid_identifier=&gt;openid_identifier
+              attempted_record.save do |result|
+                if result
+                  true
+                else
+                  false
+                end
+              end
+            else
+              errors.add(:openid_identifier, &quot;did not match any users in our database, have you set up your account to use OpenID?&quot;)
+            end
+            return
+          end
           controller.send(:authenticate_with_open_id, openid_identifier, :return_to =&gt; controller.url_for(:for_session =&gt; &quot;1&quot;, :remember_me =&gt; remember_me?)) do |result, openid_identifier|
             if result.unsuccessful?
               errors.add_to_base(result.message)
               return
             end
             
-            self.attempted_record = klass.send(find_by_openid_identifier_method, openid_identifier)
-            
-            if !attempted_record
-              errors.add(:openid_identifier, &quot;did not match any users in our database, have you set up your account to use OpenID?&quot;)
-              return
-            end
           end
         end
         </diff>
      <filename>lib/authlogic_openid/session.rb</filename>
    </modified>
    <modified>
      <diff>@@ -41,7 +41,7 @@ module AuthlogicOpenid
 
     MAJOR = 1
     MINOR = 0
-    TINY  = 4
+    TINY  = 5
 
     # The current version as a Version instance
     CURRENT = new(MAJOR, MINOR, TINY)</diff>
      <filename>lib/authlogic_openid/version.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>9a95f15676e2dfd421568305fe8421eefba99000</id>
    </parent>
  </parents>
  <author>
    <name>Pelle Braendgaard</name>
    <email>pelleb@gmail.com</email>
  </author>
  <url>http://github.com/binarylogic/authlogic_openid/commit/23c5f5da44a04745b137451ba5bacf31c464a709</url>
  <id>23c5f5da44a04745b137451ba5bacf31c464a709</id>
  <committed-date>2009-06-20T01:24:31-07:00</committed-date>
  <authored-date>2009-06-18T07:38:16-07:00</authored-date>
  <message>Supports Auto Registration of users using the auto_register method in Session.
Fixes sreg support so it supports any amount of sreg fields.

Signed-off-by: Ben Johnson &lt;bjohnson@binarylogic.com&gt;</message>
  <tree>77528160814dc2d6cf69ccd6615c37ae4cab5293</tree>
  <committer>
    <name>Ben Johnson</name>
    <email>bjohnson@binarylogic.com</email>
  </committer>
</commit>
