app/controllers/users/omniauth_callbacks_controller.rb
class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController
def github
# You need to implement the method below in your model (e.g. app/models/user.rb)
@user = User.find_for_github_oauth(request.env["omniauth.auth"])
if @user.persisted?
sign_in_and_redirect @user, :event => :authentication
set_flash_message(:notice, :success, :kind => "GitHub") if is_navigational_format?
else
session["devise.github_data"] = request.env["omniauth.auth"]
redirect_to new_user_registration_url
end
end
def bitbucket
# You need to implement the method below in your model (e.g. app/models/user.rb)
binding.pry
@user = User.find_for_bitbucket_oauth(request.env["omniauth.auth"])
if @user.persisted?
sign_in_and_redirect @user, :event => :authentication #this will throw if @user is not activated
set_flash_message(:notice, :success, :kind => "Bitbucket") if is_navigational_format?
else
session["devise.bitbucket_data"] = request.env["omniauth.auth"]
redirect_to new_user_registration_url
end
end
def twitter
@user = User.find_for_twitter_oauth(request.env["omniauth.auth"])
if @user.persisted?
sign_in_and_redirect @user, :event => :authentication #this will throw if @user is not activated
set_flash_message(:notice, :success, :kind => "Twitter") if is_navigational_format?
else
session["devise.twitter_data"] = request.env["omniauth.auth"]
flash[:notice] = 'We are unable to log you in. Let us know at support@hashtagevent.me'
redirect_to root_path
end
end
end