Sha256: 41bfa59ee04796c694c6c3250e93bb2ffa6f2931a5fc0a6ab9ce5d81181255dc

Contents?: true

Size: 751 Bytes

Versions: 26

Compression:

Stored size: 751 Bytes

Contents

module Authenticate
  extend ActiveSupport::Concern

  included do
    before_action :authenticate!
    before_action :ensure_email_is_verified! if User.include?(MustVerifyEmail)
  end

  class_methods do
    def skip_authenticate(**options)
      skip_before_action :authenticate!, **options
      skip_ensure_email_is_verified(**options)
    end

    def skip_ensure_email_is_verified(**options)
      skip_before_action :ensure_email_is_verified!, **options if User.include?(MustVerifyEmail)
    end
  end

  private

  def authenticate!
    redirect_to login_path unless Current.auth.check?
  end

  def ensure_email_is_verified!
    redirect_to verification_notice_path unless Current.auth.user && Current.auth.user.has_verified_email?
  end
end

Version data entries

26 entries across 13 versions & 1 rubygems

Version Path
kaze-1.0.1 stubs/hotwire/app/controllers/concerns/authenticate.rb
kaze-1.0.1 stubs/inertia-common/app/controllers/concerns/authenticate.rb
kaze-1.0.0 stubs/hotwire/app/controllers/concerns/authenticate.rb
kaze-1.0.0 stubs/inertia-common/app/controllers/concerns/authenticate.rb
kaze-0.19.0 stubs/hotwire/app/controllers/concerns/authenticate.rb
kaze-0.19.0 stubs/inertia-common/app/controllers/concerns/authenticate.rb
kaze-0.18.0 stubs/inertia-common/app/controllers/concerns/authenticate.rb
kaze-0.18.0 stubs/hotwire/app/controllers/concerns/authenticate.rb
kaze-0.17.0 stubs/hotwire/app/controllers/concerns/authenticate.rb
kaze-0.17.0 stubs/inertia-common/app/controllers/concerns/authenticate.rb
kaze-0.16.0 stubs/inertia-common/app/controllers/concerns/authenticate.rb
kaze-0.16.0 stubs/hotwire/app/controllers/concerns/authenticate.rb
kaze-0.15.0 stubs/hotwire/app/controllers/concerns/authenticate.rb
kaze-0.15.0 stubs/inertia-common/app/controllers/concerns/authenticate.rb
kaze-0.14.0 stubs/hotwire/app/controllers/concerns/authenticate.rb
kaze-0.14.0 stubs/inertia-common/app/controllers/concerns/authenticate.rb
kaze-0.13.0 stubs/hotwire/app/controllers/concerns/authenticate.rb
kaze-0.13.0 stubs/inertia-common/app/controllers/concerns/authenticate.rb
kaze-0.12.0 stubs/hotwire/app/controllers/concerns/authenticate.rb
kaze-0.12.0 stubs/inertia-common/app/controllers/concerns/authenticate.rb