handle errors and fix join form

This commit is contained in:
Josh
2018-06-11 13:05:54 -04:00
parent 2b0f75e62b
commit 2b065eb7fa
23 changed files with 114 additions and 239 deletions

View File

@ -35,14 +35,6 @@ class ApplicationController < ActionController::Base
end
helper_method :allow_greenlight_users?
# Generate a URL to start a meeting.
def owner_meeting_url
opts = default_meeting_options
opts[:user_is_moderator] = true
@room.meeting.join_path(current_user.name, opts)
end
helper_method :owner_meeting_url
# Determines if a form field needs the is-invalid class.
def form_is_invalid?(obj, key)
'is-invalid' if !obj.errors.messages[key].empty?

View File

@ -0,0 +1,14 @@
class ErrorsController < ApplicationController
def not_found
render status: 404
end
def unprocessable
render status: 422
end
def internal_error
render status: 500
end
end

View File

@ -35,14 +35,18 @@ class RoomsController < ApplicationController
opts = default_meeting_options
# Assign join name if passed.
if params[@room.invite_path]
if params[@room.invite_path][:join_name]
@join_name = params[@room.invite_path][:join_name]
else
# Join name not passed.
return
end
if @room.is_running?
if current_user
redirect_to @room.join_path(current_user, opts)
elsif join_name = params[:join_name] || params[@room.invite_path][:join_name]
redirect_to @room.join_path(current_user.name, opts, current_user.uid)
else
join_name = params[@room.invite_path][:join_name]
redirect_to @room.join_path(join_name, opts)
end
else
@ -65,7 +69,7 @@ class RoomsController < ApplicationController
opts = default_meeting_options
opts[:user_is_moderator] = true
redirect_to @room.join_path(current_user, opts)
redirect_to @room.join_path(current_user.name, opts, current_user.uid)
# Notify users that the room has started.
# Delay 5 seconds to allow for server start, although the request will retry until it succeeds.