forked from External/greenlight
GRN2-xx: Replaced bbb_id field with a better string generator (#1250)
* Replaced bbb_id field with a better string generator * Update room.rb How about this instead @farhatahmad ? * Update room.rb Co-authored-by: Jesus Federico <jesus@123it.ca>
This commit is contained in:
parent
10ef20363a
commit
f4990b4523
|
@ -85,7 +85,7 @@ class Room < ApplicationRecord
|
|||
# Generates a uid for the room and BigBlueButton.
|
||||
def setup
|
||||
self.uid = random_room_uid
|
||||
self.bbb_id = Digest::SHA1.hexdigest(Rails.application.secrets[:secret_key_base] + Time.now.to_i.to_s).to_s
|
||||
self.bbb_id = unique_bbb_id
|
||||
self.moderator_pw = RandomPassword.generate(length: 12)
|
||||
self.attendee_pw = RandomPassword.generate(length: 12)
|
||||
end
|
||||
|
@ -100,4 +100,12 @@ class Room < ApplicationRecord
|
|||
def random_room_uid
|
||||
[owner.name_chunk, uid_chunk, uid_chunk].join('-').downcase
|
||||
end
|
||||
|
||||
# Generates a unique bbb_id based on uuid.
|
||||
def unique_bbb_id
|
||||
loop do
|
||||
bbb_id = SecureRandom.hex(20)
|
||||
break bbb_id unless Room.exists?(bbb_id: bbb_id)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue