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:
parent
8db9ffbd8b
commit
af75583b23
@ -69,7 +69,7 @@ class AttachmentsController < ApplicationController
|
|||||||
|
|
||||||
@attachment = Attachment.new(:file => request.body)
|
@attachment = Attachment.new(:file => request.body)
|
||||||
@attachment.author = User.current
|
@attachment.author = User.current
|
||||||
@attachment.filename = ActiveSupport::SecureRandom.hex(16)
|
@attachment.filename = Redmine::Utils.random_hex(16)
|
||||||
|
|
||||||
if @attachment.save
|
if @attachment.save
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
|
@ -367,11 +367,11 @@ class MailHandler < ActionMailer::Base
|
|||||||
user.lastname = '-' if user.lastname.blank?
|
user.lastname = '-' if user.lastname.blank?
|
||||||
|
|
||||||
password_length = [Setting.password_min_length.to_i, 10].max
|
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
|
user.language = Setting.default_language
|
||||||
|
|
||||||
unless user.valid?
|
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.firstname = "-" unless user.errors[:firstname].blank?
|
||||||
user.lastname = "-" unless user.errors[:lastname].blank?
|
user.lastname = "-" unless user.errors[:lastname].blank?
|
||||||
end
|
end
|
||||||
|
@ -39,7 +39,7 @@ class Token < ActiveRecord::Base
|
|||||||
|
|
||||||
private
|
private
|
||||||
def self.generate_token_value
|
def self.generate_token_value
|
||||||
ActiveSupport::SecureRandom.hex(20)
|
Redmine::Utils.random_hex(20)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Removes obsolete tokens (same user and action)
|
# Removes obsolete tokens (same user and action)
|
||||||
|
@ -610,7 +610,7 @@ class User < Principal
|
|||||||
|
|
||||||
# Returns a 128bits random salt as a hex string (32 chars long)
|
# Returns a 128bits random salt as a hex string (32 chars long)
|
||||||
def self.generate_salt
|
def self.generate_salt
|
||||||
ActiveSupport::SecureRandom.hex(16)
|
Redmine::Utils.random_hex(16)
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@ -33,6 +33,13 @@ module Redmine
|
|||||||
ActionController::AbstractRequest.relative_url_root=arg
|
ActionController::AbstractRequest.relative_url_root=arg
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Generates a n bytes random hex string
|
||||||
|
# Example:
|
||||||
|
# random_hex(4) # => "89b8c729"
|
||||||
|
def random_hex(n)
|
||||||
|
ActiveSupport::SecureRandom.hex(n)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user