Browse files

use ActiveSupport::SecureRandom instead of rand()

  • Loading branch information...
1 parent ea1ec87 commit d624029a55f3edcf3a8c2d8ec2364d3df4b7be42 @moomerman moomerman committed Jun 25, 2011
Showing with 2 additions and 1 deletion.
  1. +2 −1 app/models/session.rb
View
3 app/models/session.rb
@@ -84,7 +84,8 @@ def assign_unique_key!
# Assigns a time-sensitive random validation key
def assign_unique_key
- self.unique_key = rand(10 ** 5).to_s.rjust(5,'0') # zero padded random 5 digits
+ # generate zero padded random 5 digits
+ self.unique_key = ActiveSupport::SecureRandom.random_number(10 **5).to_s.rjust(5,'0')
self.unique_key_generated_at = Time.now.utc
end
end

0 comments on commit d624029

Please sign in to comment.