Adds Redmine::Utils.random_hex for generating a random hex string.

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@9071 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang
2012-03-04 11:05:02 +00:00
parent 8db9ffbd8b
commit af75583b23
5 changed files with 12 additions and 5 deletions
+2 -2
View File
@@ -367,11 +367,11 @@ class MailHandler < ActionMailer::Base
user.lastname = '-' if user.lastname.blank?
password_length = [Setting.password_min_length.to_i, 10].max
user.password = ActiveSupport::SecureRandom.hex(password_length / 2 + 1)
user.password = Redmine::Utils.random_hex(password_length / 2 + 1)
user.language = Setting.default_language
unless user.valid?
user.login = "user#{ActiveSupport::SecureRandom.hex(6)}" unless user.errors[:login].blank?
user.login = "user#{Redmine::Utils.random_hex(6)}" unless user.errors[:login].blank?
user.firstname = "-" unless user.errors[:firstname].blank?
user.lastname = "-" unless user.errors[:lastname].blank?
end