Sha256: 19d3fe9a45bcf8b3c29015d5a926a83bb321c509545e529bc6a62fd7ca082ec3

Contents?: true

Size: 535 Bytes

Versions: 1

Compression:

Stored size: 535 Bytes

Contents

# frozen_string_literal: true

module Logux
  module Process
    class Auth
      attr_reader :stream, :chunk

      def initialize(stream:, chunk:)
        @stream = stream
        @chunk = chunk
      end

      def call
        authed = Logux.configuration.auth_rule.call(user_id, chunk.credentials)
        return stream.write(['authenticated', chunk.auth_id]) if authed

        stream.write(['denied', chunk.auth_id])
      end

      private

      def user_id
        chunk.node_id.split(':').first
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
logux_rails-0.1.0 lib/logux/process/auth.rb