class OmniauthController < ApplicationController before_filter :authenticate_user!, :only => [ :logout ] def success session[:user_id] = env['omniauth.auth'] user = User.new_from_omniauth(session[:user_id]) redirect_to request.env['omniauth.origin'] || root_path, notice: "Successfully logged in" end def failure flash[:alert] = params[:message] #remember to add a template to render out or redirect to somewhere end # logout - Clear our rack session BUT essentially redirect to the provider to clean up the Devise session from there too ! def login params[:provider] = "infinum" if !params[:provider] redirect_to "/auth/#{params[:provider]}?redirect_to=#{root_url}" end def logout session[:user_id] = nil redirect_to "#{ENV['omniauth_infinum_url']}/users/sign_out?redirect_to=#{root_url}", notice: 'You have successfully signed out!' end end