RailsCasts Pro episodes are now free!
Learn more or hide this
GitHub User: bertsinnema
I also have this problem. And i can't seem to find out how this is fixed
My code:
class AuthenticationsController < ApplicationController def index @authentications = current_user.authentications if current_user end def create omniauth = request.env["omniauth.auth"] authentication = Authentication.where(:provider => omniauth['provider'], :uid => omniauth['uid']).first if authentication && defined? authentication.user flash[:notice] = "Signed in successfully." sign_in_and_redirect(:user, authentication.user) elsif current_user current_user.authentications.create!(:provider => omniauth['provider'], :uid => omniauth['uid'], :token => omniauth['credentials']['token'] ) flash[:notice] = "Authentication successful." redirect_to authentications_url else user = User.new user.apply_omniauth(omniauth) if user.save flash[:notice] = "Signed in successfully." sign_in_and_redirect(:user, user) else session[:omniauth] = omniauth.except('extra') redirect_to new_user_registration_url end end end protected # This is necessary since Rails 3.0.4 # See https://github.com/intridea/omniauth/issues/185 # and http://www.arailsdemo.com/posts/44 def handle_unverified_request true end end
I also have this problem. And i can't seem to find out how this is fixed
My code: