Sha256: 1fae3e8cfbea8a2309723bdb6658b37b6b81ca559be9b5564871dd760ee32275

Contents?: true

Size: 827 Bytes

Versions: 5

Compression:

Stored size: 827 Bytes

Contents

# frozen_string_literal: true
module Omniauth
  module Rails
    module AuthenticationConcern
      extend ActiveSupport::Concern

      included do
        include Omniauth::Rails::ApplicationHelper
      end

      module ClassMethods
        private

        def require_authentication
          before_action :require_authentication
        end
      end

      private

      def require_authentication
        if Configuration.dev_mode
          ::Rails.logger.info "Omniauth::Rails: dev_mode is enabled. Skipping 'require_authentication'"
          return
        end

        redirect_to_sign_in_url unless authenticated?
      end

      def redirect_to_sign_in_url
        flash[:url_to_return_to_after_authentication] = request.original_url
        redirect_to omniauth_rails.sign_in_url
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
omniauth-rails-0.6.0 app/controllers/omniauth/rails/authentication_concern.rb
omniauth-rails-0.5.0 app/controllers/omniauth/rails/authentication_concern.rb
omniauth-rails-0.4.0 app/controllers/omniauth/rails/authentication_concern.rb
omniauth-rails-0.3.0 app/controllers/omniauth/rails/authentication_concern.rb
omniauth-rails-0.2.0 app/controllers/omniauth/rails/authentication_concern.rb