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 -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
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 On Dec 22, 1:45 am, Stephen <stephen.sieg...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> 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-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
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...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 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 > > On Dec 22, 1:45 am, Stephen <stephen.sieg...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > 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-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
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/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
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 -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.