Module: OmniauthControllerHelpers

Defined in:
app/helpers/omniauth_controller_helpers.rb

Instance Method Summary collapse

Instance Method Details

#authenticate!Object



16
17
18
# File 'app/helpers/omniauth_controller_helpers.rb', line 16

def authenticate!
  user_signed_in? || redirect_to((request.env["HTTP_REFERER"].blank?) ? root_path : :back, notice: "Voce precisa estar logado...")
end

#current_userObject



5
6
7
8
9
10
# File 'app/helpers/omniauth_controller_helpers.rb', line 5

def current_user
  @current_user ||= User.find(session[:user_id]) if session[:user_id]
rescue ActiveRecord::RecordNotFound
  session.delete(:user_id)
  nil
end

#save_return_pathObject



2
3
4
# File 'app/helpers/omniauth_controller_helpers.rb', line 2

def save_return_path
  session[:return_path] = request.path
end

#user_signed_in?Boolean

Returns:

  • (Boolean)


12
13
14
# File 'app/helpers/omniauth_controller_helpers.rb', line 12

def user_signed_in?
  !current_user.nil?
end