Class: OmniauthController

Inherits:
ApplicationController
  • Object
show all
Defined in:
lib/generators/infinum/omniauth/templates/rails/app/controllers/omniauth_controller.rb

Instance Method Summary collapse

Instance Method Details

#failureObject



10
11
12
13
# File 'lib/generators/infinum/omniauth/templates/rails/app/controllers/omniauth_controller.rb', line 10

def failure
	flash[:alert] = params[:message]
	#remember to add a template to render out or redirect to somewhere
end

#loginObject

logout - Clear our rack session BUT essentially redirect to the provider to clean up the Devise session from there too !



16
17
18
19
# File 'lib/generators/infinum/omniauth/templates/rails/app/controllers/omniauth_controller.rb', line 16

def 
	params[:provider] = "infinum" if !params[:provider]
	redirect_to "/auth/#{params[:provider]}?redirect_to=#{root_url}"
end

#logoutObject



21
22
23
24
# File 'lib/generators/infinum/omniauth/templates/rails/app/controllers/omniauth_controller.rb', line 21

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

#successObject



4
5
6
7
8
# File 'lib/generators/infinum/omniauth/templates/rails/app/controllers/omniauth_controller.rb', line 4

def success
	session[:user_id] = env['omniauth.auth']
	user = USER_MODEL.new_from_omniauth(session[:user_id])
	redirect_to request.env['omniauth.origin'] || root_path, notice: "Successfully logged in"
end