Sha256: 9c187a54a314bda7456a9501c458832141e3b656630149d06dd551d709c4b292

Contents?: true

Size: 556 Bytes

Versions: 5

Compression:

Stored size: 556 Bytes

Contents

# frozen_string_literal: true

module Masks
  module Credentials
    # Checks :factor2 for a valid backup code.
    class BackupCode < Masks::Credential
      include Factor2

      private

      def param
        :backup_code
      end

      def secret
        actor&.backup_codes if actor&.saved_backup_codes?
      end

      def verify(code)
        code if secret&.fetch(code, false)
      end

      def backup
        return unless verified?

        actor.update_attribute("backup_codes", secret.merge(code => false))
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

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