Skip to content

Commit

Permalink
Store a random user id for unauthenticated users as a cookie (#1364)
Browse files Browse the repository at this point in the history
  • Loading branch information
farhatahmad committed Apr 22, 2020
1 parent bbec5bd commit 855694c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
18 changes: 17 additions & 1 deletion app/controllers/concerns/joiner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ def join_room(opts)
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
Expand Down Expand Up @@ -92,4 +93,19 @@ def default_meeting_options
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
2 changes: 1 addition & 1 deletion spec/controllers/rooms_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ def random_valid_room_params
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
Expand Down

0 comments on commit 855694c

Please sign in to comment.