diff --git a/app/controllers/rooms_controller.rb b/app/controllers/rooms_controller.rb index f6a2e6c9..e7cfc477 100644 --- a/app/controllers/rooms_controller.rb +++ b/app/controllers/rooms_controller.rb @@ -56,6 +56,15 @@ class RoomsController < ApplicationController @recordings = recs @is_running = @room.running? else + # Get users name + @name = if current_user + current_user.name + elsif cookies.encrypted[:greenlight_name] + cookies.encrypted[:greenlight_name] + else + "" + end + render :join end end @@ -91,6 +100,9 @@ class RoomsController < ApplicationController end end + # create or update cookie with join name + cookies.encrypted[:greenlight_name] = @join_name unless cookies.encrypted[:greenlight_name] == @join_name + if @room.running? || @room.owned_by?(current_user) # Determine if the user needs to join as a moderator. opts[:user_is_moderator] = @room.owned_by?(current_user) diff --git a/app/views/rooms/join.html.erb b/app/views/rooms/join.html.erb index ddb35520..b2b3f63b 100644 --- a/app/views/rooms/join.html.erb +++ b/app/views/rooms/join.html.erb @@ -20,7 +20,7 @@ required: true, class: "form-control join-form", placeholder: t("enter_your_name"), - value: "#{current_user ? current_user.name : ''}", + value: "#{@name}", readonly: !current_user.nil? %> <%= f.submit t("room.join"), class: "btn btn-primary btn-sm col-sm-3 form-control join-form" %>