Sha256: cf23805ae93c1b17f8fffebf3898c7fa079fc4003f7b2c5f093c78c989d2cd8c

Contents?: true

Size: 763 Bytes

Versions: 3

Compression:

Stored size: 763 Bytes

Contents

# frozen_string_literal: true

module MinimalistAuthentication
  module Conversions
    class MergePasswordHash
      class << self
        def run!
          user_model.where(using_digest_version: 3, password_hash: nil).each do |user|
            new(user).update!
          end
        end

        private

        def user_model
          MinimalistAuthentication.configuration.user_model
        end
      end

      attr_accessor :user

      delegate :salt, :crypted_password, to: :user

      def initialize(user)
        self.user = user
      end

      def update!
        user.update_column(:password_hash, merged_password_hash)
      end

      private

      def merged_password_hash
        "#{salt}#{crypted_password}"
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
minimalist_authentication-2.5.2 lib/minimalist_authentication/conversions/merge_password_hash.rb
minimalist_authentication-2.5.1 lib/minimalist_authentication/conversions/merge_password_hash.rb
minimalist_authentication-2.5.0 lib/minimalist_authentication/conversions/merge_password_hash.rb