refactor: switch to use SecureRandom for random strings

This commit is contained in:
Adam Cooke
2024-03-04 17:33:25 +00:00
parent cae4b63599
commit ce30c070bd
6 changed files with 6 additions and 8 deletions
+1 -1
View File
@@ -30,7 +30,7 @@ module HasAuthentication
end
def begin_password_reset(return_to = nil)
self.password_reset_token = Nifty::Utils::RandomString.generate(length: 24)
self.password_reset_token = SecureRandom.alphanumeric(24)
self.password_reset_token_valid_until = 1.day.from_now
save!
AppMailer.password_reset(self, return_to).deliver
+1 -1
View File
@@ -164,7 +164,7 @@ class Domain < ApplicationRecord
return unless verification_method_changed?
if verification_method == "DNS"
self.verification_token = Nifty::Utils::RandomString.generate(length: 32)
self.verification_token = SecureRandom.alphanumeric(32)
elsif verification_method == "Email"
self.verification_token = rand(999_999).to_s.ljust(6, "0")
else