Sha256: 61237ff9dba9b5372f6090439688d47a89886f00daa6facc43345b9d281559a8

Contents?: true

Size: 795 Bytes

Versions: 2

Compression:

Stored size: 795 Bytes

Contents

# frozen_string_literal: true

module Keycard
  module Authentication
    # Identity verification based on an authorization token.
    #
    # The bound finder method is expected to take one parameter, the token as
    # presented by the user. This will typically need to be digested for
    # comparison with a stored version.
    class AuthToken < Method
      def apply
        if token.nil?
          skipped("No auth_token found in request attributes")
        elsif (account = finder.call(token))
          succeeded(account, "Account found for supplied Authorization Token", csrf_safe: true)
        else
          failed("Account not found for supplied Authorization Token")
        end
      end

      private

      def token
        attributes.auth_token
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
keycard-0.3.4 lib/keycard/authentication/auth_token.rb
keycard-0.3.3 lib/keycard/authentication/auth_token.rb