Sha256: faa061be7a7c908b5f2171e7f5d23001bac0aaed1f52d582a2e09c873aef5675

Contents?: true

Size: 768 Bytes

Versions: 9

Compression:

Stored size: 768 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).find_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

9 entries across 9 versions & 1 rubygems

Version Path
minimalist_authentication-3.2.2 lib/minimalist_authentication/conversions/merge_password_hash.rb
minimalist_authentication-3.2.1 lib/minimalist_authentication/conversions/merge_password_hash.rb
minimalist_authentication-3.2.0 lib/minimalist_authentication/conversions/merge_password_hash.rb
minimalist_authentication-3.1.0 lib/minimalist_authentication/conversions/merge_password_hash.rb
minimalist_authentication-3.0.0 lib/minimalist_authentication/conversions/merge_password_hash.rb
minimalist_authentication-2.7.0 lib/minimalist_authentication/conversions/merge_password_hash.rb
minimalist_authentication-2.6.2 lib/minimalist_authentication/conversions/merge_password_hash.rb
minimalist_authentication-2.6.1 lib/minimalist_authentication/conversions/merge_password_hash.rb
minimalist_authentication-2.6.0 lib/minimalist_authentication/conversions/merge_password_hash.rb