Store a random user id for unauthenticated users as a cookie (#1364)

This commit is contained in:
Ahmad Farhat 2020-04-22 09:46:21 -04:00 committed by GitHub
parent bbec5bdf2d
commit 855694c716
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 2 deletions

View File

@ -62,7 +62,8 @@ module Joiner
redirect_to join_path(@room, current_user.name, opts, current_user.uid)
else
join_name = params[:join_name] || params[@room.invite_path][:join_name]
redirect_to join_path(@room, join_name, opts)
redirect_to join_path(@room, join_name, opts, fetch_guest_id)
end
else
search_params = params[@room.invite_path] || params
@ -92,4 +93,19 @@ module Joiner
recording_default_visibility: @settings.get_value("Default Recording Visibility") == "public"
}
end
private
def fetch_guest_id
return cookies[:guest_id] if cookies[:guest_id].present?
guest_id = "gl-guest-#{SecureRandom.hex(12)}"
cookies[:guest_id] = {
value: guest_id,
expires: 1.day.from_now
}
guest_id
end
end

View File

@ -248,7 +248,7 @@ describe RoomsController, type: :controller do
allow_any_instance_of(BigBlueButton::BigBlueButtonApi).to receive(:is_meeting_running?).and_return(true)
post :join, params: { room_uid: @room, join_name: "Join Name" }
expect(response).to redirect_to(join_path(@owner.main_room, "Join Name", {}))
expect(response).to redirect_to(join_path(@owner.main_room, "Join Name", {}, response.cookies["guest_id"]))
end
it "should render wait if meeting isn't running" do