Method: DeviseController#require_no_authentication
- Defined in:
- app/controllers/devise_controller.rb
#require_no_authentication ⇒ Object (protected)
Helper for use in before_filters where no authentication is required.
Example:
before_filter :require_no_authentication, only: :new
96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 |
# File 'app/controllers/devise_controller.rb', line 96 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) flash[:alert] = I18n.t("devise.failure.already_authenticated") redirect_to after_sign_in_path_for(resource) end end |