<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -162,9 +162,10 @@ class OpenIdAuthenticatedGenerator &lt; Rails::Generator::NamedBase
         puts &quot;Don't forget to:&quot;
         puts
         puts &quot;  - add restful routes in config/routes.rb&quot;
-        puts &quot;    map.resource :#{model_controller_file_name}, :#{controller_file_name}&quot;
-        puts &quot;    map.activate '/activate/:activation_code', :controller =&gt; '#{model_controller_file_name}', :action =&gt; 'activate'&quot;
+        puts &quot;    map.resources :#{model_controller_file_name}&quot;
+        puts &quot;    map.resource :#{controller_file_name}, :collection =&gt; { :begin =&gt; :post, :complete =&gt; :get }&quot;
         if options[:include_activation]
+          puts &quot;    map.activate '/activate/:activation_code', :controller =&gt; '#{model_controller_file_name}', :action =&gt; 'activate'&quot;
           puts
           puts &quot;  - add an observer to config/environment.rb&quot;
           puts &quot;    config.active_record.observers = :#{file_name}_observer&quot;
@@ -173,7 +174,7 @@ class OpenIdAuthenticatedGenerator &lt; Rails::Generator::NamedBase
         puts &quot;Try these for some familiar login URLs if you like:&quot;
         puts
         puts &quot;  map.signup '/signup', :controller =&gt; '#{model_controller_file_name}', :action =&gt; 'new'&quot;
-        puts &quot;  map.login  '/login', :controller =&gt; '#{controller_file_name}', :action =&gt; 'new'&quot;
+        puts &quot;  map.login  '/login',  :controller =&gt; '#{controller_file_name}', :action =&gt; 'new'&quot;
         puts &quot;  map.logout '/logout', :controller =&gt; '#{controller_file_name}', :action =&gt; 'destroy'&quot;
         puts
         puts (&quot;-&quot; * 70)
@@ -182,7 +183,7 @@ class OpenIdAuthenticatedGenerator &lt; Rails::Generator::NamedBase
         puts
         puts (&quot;-&quot; * 70)
         puts
-        puts &quot;Thanks for using restful_authentication&quot;
+        puts &quot;Thanks for using restful_open_id_authentication&quot;
         puts
         puts &quot;Don't forget to comment out the observer line in environment.rb&quot;
         puts &quot;  (This was optional so it may not even be there)&quot;</diff>
      <filename>generators/open_id_authenticated/open_id_authenticated_generator.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,10 +1,9 @@
-# might using the ruby-openid gem
 begin
-  require 'rubygems'
+  gem 'ruby-openid'
+  require 'openid'
 rescue LoadError
-  nil
+  puts &quot;Install the ruby-openid gem to enable OpenID support&quot;
 end
-require 'openid'
 require 'open_id_store'
 require 'controller_methods'
 </diff>
      <filename>init.rb</filename>
    </modified>
    <modified>
      <diff>@@ -14,6 +14,7 @@ module OpenIdConsumer
     end
 
     protected
+    
       def open_id_consumer
         @open_id_consumer ||= OpenID::Consumer.new(
           session[:open_id_session] ||= {}, 
@@ -34,6 +35,91 @@ module OpenIdConsumer
         logger.debug @open_id_fields.inspect
         logger.debug &quot;***************** sreg params ***************&quot;
       end
+      
+      
+      def authenticate_with_open_id(identity_url)
+        @open_id_response = open_id_consumer.begin(identity_url)
+        yield(@open_id_response.status.to_sum)
+        
+        # If the URL was unusable (either because of network conditions, a server error, 
+        # or that the response returned was not an OpenID identity page), the library 
+        # will return HTTP_FAILURE or PARSE_ERROR. Let the user know that the URL is unusable.
+        case open_id_response.status
+          when OpenID::SUCCESS
+            add_sreg_params!(@open_id_response)
+            redirect_to open_id_response.redirect_url((request.protocol + request.host_with_port + &quot;/&quot;), complete_session_url)
+          else
+            flash[:error] = &quot;Unable to find OpenID server for &lt;q&gt;#{params[:open_id_url]}&lt;/q&gt;&quot;
+            render :action =&gt; :new
+        end
+      end
+
+      def complete
+        case open_id_response.status
+          when OpenID::FAILURE
+            # In the case of failure, if info is non-nil, it is the URL that we were verifying. 
+            # We include it in the error message to help the user figure out what happened.
+            flash[:notice] = if open_id_response.identity_url
+              &quot;Verification of #{open_id_response.identity_url} failed. &quot;
+            else
+              &quot;Verification failed. &quot;
+            end
+            flash[:notice] += open_id_response.msg.to_s
+          when OpenID::SUCCESS
+            # Success means that the transaction completed without error. If info is nil, 
+            # it means that the user cancelled the verification.
+            flash[:notice] = &quot;You have successfully verified #{open_id_response.identity_url} as your identity.&quot;
+            if open_id_fields.any?
+              @user   = User.find_by_open_id_url(open_id_response.identity_url)
+              @user ||= User.new(:open_id_url =&gt; open_id_response.identity_url)
+              @user.login       = open_id_fields['nickname'] if open_id_fields['nickname']
+              @user.email       = open_id_fields['email']    if open_id_fields['email']          
+              if @user.save
+                self.current_user = @user
+                if params[:remember_me] == &quot;1&quot;
+                  self.current_user.remember_me
+                  cookies[:auth_token] = { :value =&gt; self.current_user.remember_token , :expires =&gt; self.current_user.remember_token_expires_at }
+                end
+                flash[:notice] = &quot;You have successfully verified #{open_id_response.identity_url} as your identity.&quot;
+                return redirect_back_or_default('/')
+              else
+                flash[:notice] = @user.errors.full_messages.join('&lt;br /&gt;')
+                render :action =&gt; 'new' and return
+              end
+            end
+          when OpenID::CANCEL
+            flash[:notice] = &quot;Verification cancelled.&quot;
+          else
+            flash[:notice] = &quot;Unknown response status: #{open_id_response.status}&quot;
+        end
+        redirect_to :action =&gt; 'new'
+      end
+      
+      
+      def authenticate_with_open_id(identity_url)
+        
+        
+        case status
+        when :missing
+          failed_authentication &quot;Sorry, the OpenID server couldn't be found&quot;
+ 
+        when :canceled
+          failed_authentication &quot;OpenID verification was canceled&quot;
+ 
+        when :failed
+          failed_authentication &quot;Sorry, the OpenID verification failed&quot;
+ 
+        when :successful
+          if @current_user =
+              @account.users.find_by_identity_url(identity_url)
+            successful_authentication
+          else
+            failed_authentication &quot;Sorry, no user by that identity URL exists&quot;
+          end
+        end
+      end
+      
+      
 
       def add_sreg_params!(openid_response)
         open_id_consumer_options.keys.inject({}) do |params, key|</diff>
      <filename>lib/controller_methods.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,7 +1,3 @@
-require 'association'
-require 'nonce'
-require 'setting'
-
 module OpenIdConsumer
   class OpenIdStore &lt; OpenID::Store
     def get_auth_key
@@ -68,7 +64,7 @@ module OpenIdConsumer
       false
     end
 
-    # not part of the api, but useful
+    # not part of the API, but useful
     def gc
       now = Time.now.to_i
 
@@ -81,4 +77,20 @@ module OpenIdConsumer
       assocs.each { |a| a.destroy if a.from_record.expired? } unless assocs.nil?
     end
   end
+
+  class Setting &lt; ActiveRecord::Base
+    set_table_name 'open_id_settings'
+    validates_uniqueness_of :setting
+  end
+
+  class Nonce &lt; ActiveRecord::Base
+    set_table_name 'open_id_nonces'
+  end
+
+  class Association &lt; ActiveRecord::Base
+    set_table_name 'open_id_associations'
+    def from_record
+      OpenID::Association.new(handle, secret, issued, lifetime, assoc_type)
+    end
+  end
 end
\ No newline at end of file</diff>
      <filename>lib/open_id_store.rb</filename>
    </modified>
  </modified>
  <removed type="array">
    <removed>
      <filename>lib/association.rb</filename>
    </removed>
    <removed>
      <filename>lib/nonce.rb</filename>
    </removed>
    <removed>
      <filename>lib/setting.rb</filename>
    </removed>
  </removed>
  <parents type="array">
    <parent>
      <id>43034aa18417cf1120840dff4ed7c472d19d60e7</id>
    </parent>
  </parents>
  <author>
    <name>matt</name>
    <email>matt@9e3d647a-8015-0410-9c67-decdcf36f685</email>
  </author>
  <url>http://github.com/ReinH/restful_open_id_authentication/commit/1e47c6f81d03af60415178896d4230e9b04f38a9</url>
  <id>1e47c6f81d03af60415178896d4230e9b04f38a9</id>
  <committed-date>2007-02-26T23:46:17-08:00</committed-date>
  <authored-date>2007-02-26T23:46:17-08:00</authored-date>
  <message>* Update generator messaging
* Consolidate ActiveRecord OpenID store into one file

git-svn-id: http://svn.eastmedia.com/svn/bantay/plugins/trunk/restful_open_id_authentication@40 9e3d647a-8015-0410-9c67-decdcf36f685</message>
  <tree>03b16cf1ca8d21fddab5eb23b036a889dc75e900</tree>
  <committer>
    <name>matt</name>
    <email>matt@9e3d647a-8015-0410-9c67-decdcf36f685</email>
  </committer>
</commit>
