confirmable + omniauthable, skip confirmation if OAuth sign-up

1,106 views
Skip to first unread message

Mark Westling

unread,
Dec 9, 2010, 8:16:02 AM12/9/10
to plataforma...@googlegroups.com
I'd like to allow users to sign up either the standard way or through Facebook (or some other OAuth provider). If a user registers manually, I want to confirm the email address (via confirmable), but if they come from Facebook or another provider, I want to skip the confirmation.

Any suggestions on how to approach this? Apologies in advance if the solution's out there and my searches didn't find it.

Thanks,
Mark

kadoudal

unread,
Dec 22, 2010, 5:07:51 AM12/22/10
to Devise
I have the same issue ... did you solved it ?

kadoudal

unread,
Dec 22, 2010, 5:20:39 AM12/22/10
to Devise
I just solved it ...

In the find_for_facebook_oauth action in the User model , I used the
confirm! before saving it...

def self.find_for_facebook_oauth(access_token,
signed_in_resource=nil)
data = access_token['extra']['user_hash']
if user = User.find_by_email(data["email"])
user
else # Create an user with a stub password.
user = User.new(:email => data["email"], :password =>
Devise.friendly_token[0,20], :agreement_status => true)
user.confirm!
user.save!
user
end
end


On 22 déc, 11:07, kadoudal <kadou...@gmail.com> wrote:
> I have the same issue ... did you solved it ?
>
> On 9 déc, 14:16, Mark Westling <mark.westl...@gmail.com> wrote:
>
>
>
>
>
>
>
> > I'd like to allow users to sign up either the standard way or through
> > Facebook (or some other OAuth provider). If a user registers manually, I
> > want to confirm the email address (viaconfirmable), but if they come from

an...@buildheroes.com

unread,
Mar 11, 2013, 6:37:52 AM3/11/13
to plataforma...@googlegroups.com
You have to be careful with this solution as user.confirm! saves the user without validating. So if data["email"] is empty your user makes it to the database anyways. The only solution i found was to set
self.confirmation_token = nil
self.confirmed_at = Time.now.utc

manually.

Andi
Reply all
Reply to author
Forward
0 new messages