Having trouble with Devise /OmniAuth

19 views
Skip to first unread message

Stephen

unread,
Dec 21, 2010, 10:45:56 PM12/21/10
to Ruby on Rails: Talk

Hi All,

I am using the Devise 1.2 to integrate with OmniAuth (https://
github.com/plataformatec/devise/wiki/OmniAuth:-Overview). The
authorization/callback process works fine but I am not able to access
information from the user_info hash that is passed through the
request. I have tried several things within the Users controller but I
can't seem to fill current_user.name/image/ etc. I am new to Rails
and have hit somewhat of a road block and I am just looking for some
direction. I have exhausted the options that I am familiar with...

----User Model---

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.create!(:email => data["email"], :password =>
Devise.friendly_token[0,20])
end
end

def self.new_with_session(params, session)
super.tap do |user|
if data = session["devise.facebook_data"]
user(:email => data["email"],:name =>
data["name"], :avatar_url => data["image"])
end
end
end


In the self.new_with_sessions.....I added the attributes to user
thinking that they would be created with the new session


Thanks,

Stephen

MarcRic

unread,
Dec 22, 2010, 7:23:16 PM12/22/10
to Ruby on Rails: Talk
Hi Stephen,

I have recently finished a Rails 3 course, and the instructor
recommends a Devise + CanCan combo.

If you make a research you will see this option being used all around.

Take this one as an example:

http://www.tonyamoyal.com/2010/07/28/rails-authentication-with-devise-and-cancan-customizing-devise-controllers/

All the best.

--
MarcRic
www.marcric.com
http://marcricblog.blogspot.com/
http://www.traineronrails.com/
http://groups.google.com.br/group/riorubyrails

Stephen

unread,
Dec 22, 2010, 8:06:27 PM12/22/10
to Ruby on Rails: Talk
I am using Omniauth for the purpose of connecting the user to my app
via facebook/twitter...therefore the CanCan combo wont really be of
much use unless I assign privileges to certain users in my app. The
issue I am encountering is specific to the hash of user specific
information that facebook/twitter passes into my app via the
registration callback.


thanks for the suggestion.

On Dec 22, 7:23 pm, MarcRic <marc...@gmail.com> wrote:
> Hi Stephen,
>
> I have recently finished a Rails 3 course, and the instructor
> recommends a Devise + CanCan combo.
>
> If you make a research you will see this option being used all around.
>
> Take this one as an example:
>
> http://www.tonyamoyal.com/2010/07/28/rails-authentication-with-devise...
>
> All the best.
>
> --
> MarcRicwww.marcric.comhttp://marcricblog.blogspot.com/http://www.traineronrails.com/http://groups.google.com.br/group/riorubyrails

Markus Svensson

unread,
Jan 29, 2011, 11:35:35 AM1/29/11
to rubyonra...@googlegroups.com
Hi
My guess is that you need to add your new columns (name, avatar_url) to
your attr_accessible.
/Markus

--
Posted via http://www.ruby-forum.com/.

Alpha Blue

unread,
Jan 29, 2011, 11:18:28 PM1/29/11
to rubyonra...@googlegroups.com
With something as important as authentication, I just don't see the need
to use devise. I prefer writing my own authentication solution. I've
used devise and it's very detailed. But, like many authentication
solutions out there, it never covers everything I need.

My suggestion to you is to create your own.

Here's an easy railscast that can help you with creating a very simple
solution, and one that you can eventually adapt to support omniauth.

http://railscasts.com/episodes/250-authentication-from-scratch

Reply all
Reply to author
Forward
0 new messages