Forum: Ruby on Rails issues with openid

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
997433f165140d58f52b8c0d1d005dc1?d=identicon&s=25 Patrick Aljord (Guest)
on 2007-04-23 17:18
(Received via mailing list)
hey,

I'm trying to use openid but I always get that "undefined method
`using_open_id?'" I did put require 'openid' on top of my controller,
is there anything else I should include?

this is my checklogin function:

 def checklogin
     if using_open_id?
       open_id_authentication
     elsif params[:login]
       password_authentication(params[:login], params[:password])
     end
   end

thanx in advance

Pat
997433f165140d58f52b8c0d1d005dc1?d=identicon&s=25 Patrick Aljord (Guest)
on 2007-04-24 04:38
(Received via mailing list)
any idea? :-)
E811b5337bcad19d52c8fed3a0ea0075?d=identicon&s=25 John Miller (jfmiller28)
on 2007-04-24 18:46
Patrick Aljord wrote:
> hey,
>
> I'm trying to use openid but I always get that "undefined method
> `using_open_id?'" I did put require 'openid' on top of my controller,
> is there anything else I should include?
>
> this is my checklogin function:
>
>  def checklogin
>      if using_open_id?
>        open_id_authentication
>      elsif params[:login]
>        password_authentication(params[:login], params[:password])
>      end
>    end
>
> thanx in advance
>
> Pat

More information would be helpful, but let's try this.

Your error is telling us that `using_open_id?` is not a method of the
containing class (I'm going to guess that this is in class
ApplicationController < ActionController::Base).  So, why not?

Without more information it's impossible to say.  A web search says that
you are trying to use the OpenID Authentication Plugin as described at
http://www.bencurtis.com/archives/2007/03/rails-op...
(your code is identical)

If this is the case, the first thing I'd check into is that the plugin
is installed correctly.   Can you prove that it is loading with rails?
Do you need to run install.rb?  Do you have the dependencies installed?

I will quote "Bob" in that in the forum listed above who had the same
problem:

>Ah – I missed all the hidden steps of installing the open_id_authentication plugin, 
running migrations, setting index_url, etc. It’s still not clear in the code how one 
signs up with an OpenID URL – it takes more than simply adding an openid_url field in 
signup.rhtml

Note: I'm trying to get OpenID working with a Role based Authentication
system as well and I haven't been successful yet. Anyone else who can
shed light on "all the hidden steps

John Miller
997433f165140d58f52b8c0d1d005dc1?d=identicon&s=25 Patrick Aljord (Guest)
on 2007-04-25 04:18
(Received via mailing list)
thanx I got to workalready since yesterday and it was because I didn't
install OpenIdAuthentication indeed :-)

I still have a problem though, though it allows the user to login, it
won't create it in the database:

I use this function:
 def open_id_authentication
       authenticate_with_open_id do |result, identity_url|
         if result.successful?
           if self.current_user =
User.find_or_create_by_identity_url(identity_url)
              redirect_to(:action => 'login')
       flash[:warning] = message
           else
             failed_login "Sorry, no user by that identity URL exists
(#{identity_url})"
           end
         else
           failed_login result.message
         end
       end
     end

and that part:
 if self.current_user =
User.find_or_create_by_identity_url(identity_url)
              redirect_to(:action => 'login')

seems to be ignored for some reason.

any idea what's wrong?
Fbc074aa241a81acf9709d1048cc29cb?d=identicon&s=25 Randy Walker (owossoborn)
on 2007-07-16 03:44
Patrick Aljord wrote:
> thanx I got to workalready since yesterday and it was because I didn't
> install OpenIdAuthentication indeed :-)
>
> I still have a problem though, though it allows the user to login, it
> won't create it in the database:
>
> I use this function:
>  def open_id_authentication
>        authenticate_with_open_id do |result, identity_url|
>          if result.successful?
>            if self.current_user =
> User.find_or_create_by_identity_url(identity_url)
>               redirect_to(:action => 'login')
>        flash[:warning] = message
>            else
>              failed_login "Sorry, no user by that identity URL exists
> (#{identity_url})"
>            end
>          else
>            failed_login result.message
>          end
>        end
>      end
>
> and that part:
>  if self.current_user =
> User.find_or_create_by_identity_url(identity_url)
>               redirect_to(:action => 'login')
>
> seems to be ignored for some reason.
>
> any idea what's wrong?

Do you have any validations in your model that might be preventing
account creation?  I had to ad :if => :not_openid? to the end of most of
my validations.  ie.with OpenID login, you won't have a username,
password, password-length will be too short, etc.

However, mine works only in development mode.  In production, it appears
as though I'm getting the same response from myopenid.com, but it throws
an error "connection refused - connect(2)".  Upon page refresh, the site
comes back and the flash shows "Sorry, the openid verification failed."
I can restart the server in development mode and it works again.
This topic is locked and can not be replied to.