Method: DeviseController#require_no_authentication
- Defined in:
- app/controllers/devise_controller.rb
#require_no_authentication ⇒ Object (protected)
Helper for use in before_actions where no authentication is required.
Example:
before_action :require_no_authentication, only: :new
116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 |
# File 'app/controllers/devise_controller.rb', line 116 def require_no_authentication assert_is_devise_resource! return unless no_input = devise_mapping.no_input_strategies authenticated = if no_input.present? args = no_input.dup.push scope: resource_name warden.authenticate?(*args) else warden.authenticated?(resource_name) end if authenticated && resource = warden.user(resource_name) (:alert, 'already_authenticated', scope: 'devise.failure') redirect_to after_sign_in_path_for(resource) end end |