Module: Reusable::Rails::Controllers::AuthenticationFilters

Extended by:
ActiveSupport::Concern
Defined in:
lib/reusable/rails/controllers/authentication_filters.rb

Instance Method Summary collapse

Methods included from ActiveSupport::Concern

append_features, extended, included

Instance Method Details

#ensure_no_userObject

Filter method for ensuring a user session does not exist for the given request.



30
31
32
33
34
35
36
37
38
# File 'lib/reusable/rails/controllers/authentication_filters.rb', line 30

def ensure_no_user
  return true unless current_user?
  if block_given?
    yield
  else
    redirect_to root_path
    return false
  end
end

#ensure_userObject

Filter method for ensuring a user session exists for the given request.



17
18
19
20
21
22
23
24
25
# File 'lib/reusable/rails/controllers/authentication_filters.rb', line 17

def ensure_user
  return true if current_user?
  if block_given?
    yield
  else
    redirect_to root_path
    return false
  end
end