Module: ActionController::AuthenticateUser::ClassMethods

Defined in:
lib/action_controller/authenticate_user.rb

Overview

Methods available as macro-style methods on any controller

Instance Method Summary collapse

Instance Method Details

#authentication_requiredObject

Sets up the controller so that authentication is required. If the user is not authenticated then they will be redirected to the login screen.

The page requested will be saved so that once the login has occured they will be sent back to the page they first requested. If no page was requested (they went to the login page directly) then they will be directed to profiles/home after login which is a placeholder for the app to override.

Options given are passed directly to the before_action method so feel free to provide :only and :except options.



29
30
31
# File 'lib/action_controller/authenticate_user.rb', line 29

def authentication_required
  before_action :require_authentication
end

#no_authentication_requiredObject

Will remove authentication from certain actions. Options given are passed directly to skip_before_action so feel free to use :only and :except options.

This method is useful in cases where you have locked down the entire application by putting authentication_required in your ApplicationController but then want to open an action back up in a specific controller.



41
42
43
# File 'lib/action_controller/authenticate_user.rb', line 41

def no_authentication_required
  skip_before_action :require_authentication
end