forked from External/greenlight
		
	Store a random user id for unauthenticated users as a cookie (#1364)
This commit is contained in:
		@@ -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
 | 
			
		||||
 
 | 
			
		||||
@@ -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
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user