Sha256: 14b8bb85f51cf17a48007d4d607350195f46d6fd5da874896ad78eddf0f998d6

Contents?: true

Size: 785 Bytes

Versions: 24

Compression:

Stored size: 785 Bytes

Contents

# frozen_string_literal: true

module Maglev
  module AuthenticationConcern
    extend ActiveSupport::Concern

    included do
      before_action :require_authentication
    end

    private

    def require_authentication
      raise Maglev::Errors::NotAuthorized unless authenticated_in_app?

      session[:maglev_site_id] = maglev_site.id
    end

    def authenticated_in_app?
      case maglev_config.is_authenticated
      when nil
        # NOTE: this use case must not happen
        raise 'The Maglev configuration requires the is_authenticated setting. Please read the documentation.'
      when Symbol
        send(maglev_config.is_authenticated, maglev_site)
      when Proc
        instance_exec(maglev_site, &maglev_config.is_authenticated)
      end
    end
  end
end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
maglevcms-1.7.3 app/controllers/concerns/maglev/authentication_concern.rb
maglevcms-1.7.2 app/controllers/concerns/maglev/authentication_concern.rb
maglevcms-1.7.1 app/controllers/concerns/maglev/authentication_concern.rb
maglevcms-1.7.0 app/controllers/concerns/maglev/authentication_concern.rb
maglevcms-1.6.1 app/controllers/concerns/maglev/authentication_concern.rb
maglevcms-1.6.0 app/controllers/concerns/maglev/authentication_concern.rb
maglevcms-1.5.1 app/controllers/concerns/maglev/authentication_concern.rb
maglevcms-1.4.0 app/controllers/concerns/maglev/authentication_concern.rb
maglevcms-1.3.0 app/controllers/concerns/maglev/authentication_concern.rb
maglevcms-1.2.2 app/controllers/concerns/maglev/authentication_concern.rb
maglevcms-1.2.1 app/controllers/concerns/maglev/authentication_concern.rb
maglevcms-1.2.0 app/controllers/concerns/maglev/authentication_concern.rb
maglevcms-1.1.7 app/controllers/concerns/maglev/authentication_concern.rb
maglevcms-1.1.6 app/controllers/concerns/maglev/authentication_concern.rb
maglevcms-1.1.5 app/controllers/concerns/maglev/authentication_concern.rb
maglevcms-1.1.4 app/controllers/concerns/maglev/authentication_concern.rb
maglevcms-1.1.3 app/controllers/concerns/maglev/authentication_concern.rb
maglevcms-1.1.2 app/controllers/concerns/maglev/authentication_concern.rb
maglevcms-1.1.1 app/controllers/concerns/maglev/authentication_concern.rb
maglevcms-1.1.0 app/controllers/concerns/maglev/authentication_concern.rb