Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def twitter
- @user = User.from_omniauth(request.env["omniauth.auth"])
- if @user.persisted?
- flash[:notice] = I18n.t "devise.omniauth_callbacks.success", :kind => "Twitter"
- sign_in_and_redirect @user, :event => :authentication
- else
- session["devise.twitter_data"] = request.env["omniauth.auth"].except("extra")
- redirect_to twitter_register_path
- end
- end
- def self.from_omniauth(auth)
- where(provider: auth.provider, uid: auth.uid).first_or_create do |user|
- user.provider = auth.provider
- user.uid = auth.uid
- user.email = auth.info.email
- user.name = auth.info.name
- user.password = Devise.friendly_token[0,20]
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement