jrallison / authlogic_oauth

Authlogic OAuth is an extension of the Authlogic library to add OAuth support. OAuth can be used to allow users to login with their Twitter credentials.
authlogic-oauth.heroku.com
MIT License
165 stars 25 forks source link

Registration error when used in conjunction with authlogic_openid #1

Open omarkarim opened 14 years ago

omarkarim commented 14 years ago

Hello,

I'm getting an ActionController::DoubleRenderError when using authlogic_oauth to register a user with authlogic_openid also installed. The user is being saved in a block as recommended: @user.save do |result| etc...

At first glance it seems the save method could be the culprit since it's being overridden by both authlogic_openid and authlogic_oauth? Any help would be greatly appreciated.

Thanks!

jrallison commented 14 years ago

Truthfully, I've never tested authlogic_openid and authlogic_oauth in the same project, so that very well may be the case.

Can you post the contents of the controller action where the error is occurring? Just to give me a starting point.

Thanks!

omarkarim commented 14 years ago

Thanks very much for taking a look at this. I have a fairly typical authlogic UsersController with the following create action:

def create @user = User.new(params[:user]) @user.save do |result| if result flash[:notice] = "Registration successful." redirect_to root_url else render :action => 'new' end end end

jrallison commented 14 years ago

Looks like you're spot on here. Unfortunately, I don't see an easy fix for this. I've sent an email to Ben at binarylogic (who developed authlogic and authlogic_openid) to see if he has any ideas.

For now, it looks like the two are incompatible. I'll update here if the situation improves.

omarkarim commented 14 years ago

Ok great, thanks! Meanwhile, is there an option for auto-registering the user if s/he does not exist in the database when logging in for the first time? That way my UserSessionsController could cover both the login and register workflows.

jrallison commented 14 years ago

Not currently.

The downside to that is there wouldn't be anyway to capture other information from the user (such as any other required fields on the registration page).

I could add an option which allows that for the case where you only want to require the oauth token/secret for each user.

moedusa commented 14 years ago

Hello,

Having this option would be really nice. I am trying to figure out how to make it in my controller for an hour already with no luck :( - and yes, controller is that simple, and no required fields upon user exist... Seemed to be a dead simple task at the first glance...

bfolkens commented 14 years ago

FWIW I got around this with something like:


@user = User.new(params[:user])
result = @user.save
return if @performed_render || @performed_redirect

if result
  ...
else
  ...
end

and I'm using OAuth, OpenID, and Facebook...

dapi commented 14 years ago

bfoklens, your solution works for me. But it's require to password confirmation until registration for last added gem plugin (oid or oauth). First plugin works fine, but second requires passwords.

Could you present full example of code?

bfolkens commented 14 years ago

dapi: I filed a bug report here http://github.com/jrallison/authlogic_oauth/issues#issue/5 regarding that issue (with a patch if you're interested). The authlogic OpenID code has a similar issue (probably why this one does since it seems like it's based on that) so I posted a bug report and patch on that issue tracker as well.

dapi commented 14 years ago

That patch works for me fine.

I found yet another way to fix it:

class User < ActiveRecord::Base
 def require_password?
  return false if using_openid? || using_oauth?
  super
 end
end