Sha256: 75ecafe7b23f005bff74473439b312431785ecf7c355dc12dcc7310c98b0ae07

Contents?: true

Size: 748 Bytes

Versions: 5

Compression:

Stored size: 748 Bytes

Contents

# frozen_string_literal: true

module Masks
  module Credentials
    # Checks for an :actor to masquerade as.
    class Masquerade < Masks::Credential
      checks :actor

      def lookup
        return if session.actor

        value = session.data[:as]

        @loaded =
          case value
          when Masks::ANON
            Actors::Anonymous.new(session:) if session.mask&.allow_anonymous?
          when session.mask.actor_scope
            value
          when ValidateEmail.valid?(value)
            config.find_actor(session, email: value)
          when String
            config.find_actor(session, nickname: prefix_nickname(value))
          end
      end

      def maskup
        approve! if @loaded
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
masks-0.4.0 app/models/masks/credentials/masquerade.rb
masks-0.3.2 app/models/masks/credentials/masquerade.rb
masks-0.3.1 app/models/masks/credentials/masquerade.rb
masks-0.3.0 app/models/masks/credentials/masquerade.rb
masks-0.2.0 app/models/masks/credentials/masquerade.rb