mirror of
https://github.com/discourse/discourse.git
synced 2024-12-02 16:24:17 +08:00
32e261ef73
* Add migrations to ensure password hash is synced across users & user_passwords * Persist password-related data in user_passwords instead of users * Merge User#expire_old_email_tokens with User#expire_tokens_if_password_changed * Add post deploy migration to mark password-related columns from users table as read-only * Refactored UserPassword#confirm_password? and changes required to accommodate hashing the password after validations
23 lines
714 B
Ruby
23 lines
714 B
Ruby
# frozen_string_literal: true
|
|
|
|
Fabricator(:user_password) do
|
|
transient password: "myawesomefakepassword"
|
|
|
|
user { Fabricate(:user, password: nil) }
|
|
password_salt { SecureRandom.hex(UserPassword::PASSWORD_SALT_LENGTH) }
|
|
password_algorithm { UserPassword::TARGET_PASSWORD_ALGORITHM }
|
|
|
|
after_build do |user_password, transients|
|
|
if transients[:password].present?
|
|
user_password.password_hash =
|
|
PasswordHasher.hash_password(
|
|
password: transients[:password],
|
|
salt: user_password.password_salt,
|
|
algorithm: user_password.password_algorithm,
|
|
)
|
|
end
|
|
end
|
|
end
|
|
|
|
Fabricator(:expired_user_password, from: :user_password) { password_expired_at { 1.day.ago } }
|