Omniauth Voupe
Add the omniauth-voupe
gem to your Gemfile and configure as follows:
Rails.application.config.middleware.use OmniAuth::Builder do
provider :voupe, "ID", "SECRET"
end
class SessionsController < ApplicationController
def index
redirect_to "/auth/voupe"
end
def new
redirect_to "/auth/voupe"
end
def create
@user = User.find_or_create_from_auth_hash(request.env['omniauth.auth'])
session[:user_id] = @user.id
redirect_to root_path
end
end
get "/auth/voupe/callback", to: "sessions#create"
def self.find_or_create_from_auth_hash(auth_hash)
user = where(voupe_portal_token: auth_hash.uid).first_or_create
user.update(
email: auth_hash.info.email,
first_name: auth_hash.info.first_name,
last_name: auth_hash.info.last_name
)
user
end