File: update_password_hash.rb

package info (click to toggle)
ruby-rodauth 2.42.0-2
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 812 kB
  • sloc: ruby: 7,524; javascript: 100; makefile: 4
file content (30 lines) | stat: -rw-r--r-- 636 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# frozen-string-literal: true

module Rodauth
  Feature.define(:update_password_hash, :UpdatePasswordHash) do
    depends :login_password_requirements_base

    def password_match?(password)
      if (result = super) && update_password_hash?
        @update_password_hash = false
        set_password(password)
      end

      result
    end

    private

    def update_password_hash?
      password_hash_cost != @current_password_hash_cost || @update_password_hash
    end

    def get_password_hash
      if hash = super
        @current_password_hash_cost = extract_password_hash_cost(hash)
      end

      hash
    end
  end
end