2024-06-04 03:42:53 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
Fabricator(:user_password) do
|
|
|
|
transient password: "myawesomefakepassword"
|
|
|
|
|
2024-10-09 21:23:06 -04:00
|
|
|
user { Fabricate(:user, password: nil) }
|
|
|
|
password_salt { SecureRandom.hex(UserPassword::PASSWORD_SALT_LENGTH) }
|
|
|
|
password_algorithm { UserPassword::TARGET_PASSWORD_ALGORITHM }
|
2024-06-04 03:42:53 -04:00
|
|
|
|
|
|
|
after_build do |user_password, transients|
|
2024-10-09 21:23:06 -04:00
|
|
|
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
|
2024-06-04 03:42:53 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
Fabricator(:expired_user_password, from: :user_password) { password_expired_at { 1.day.ago } }
|