Fixed 404 on room join (#2092)

This commit is contained in:
Ahmad Farhat 2020-09-17 11:32:06 -04:00 committed by GitHub
parent a27884733d
commit 55dd5725b5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 5 additions and 7 deletions

View File

@ -235,7 +235,7 @@ class ApplicationController < ActionController::Base
path = if allow_greenlight_accounts? path = if allow_greenlight_accounts?
signin_path signin_path
elsif Rails.configuration.loadbalanced_configuration elsif Rails.configuration.loadbalanced_configuration
omniauth_login_url(:bn_launcher) "#{Rails.configuration.relative_url_root}/auth/bn_launcher"
else else
signin_path signin_path
end end

View File

@ -91,6 +91,7 @@ class RoomsController < ApplicationController
# GET /rooms # GET /rooms
def cant_create_rooms def cant_create_rooms
return redirect_to root_path unless current_user
shared_rooms = current_user.shared_rooms shared_rooms = current_user.shared_rooms
if current_user.shared_rooms.empty? if current_user.shared_rooms.empty?
@ -156,11 +157,8 @@ class RoomsController < ApplicationController
def join_specific_room def join_specific_room
room_uid = params[:join_room][:url].split('/').last room_uid = params[:join_room][:url].split('/').last
begin @room = Room.find_by(uid: room_uid)
@room = Room.find_by!(uid: room_uid) return redirect_to cant_create_rooms_path, alert: I18n.t("room.no_room.invalid_room_uid") unless @room
rescue ActiveRecord::RecordNotFound
return redirect_to current_user.main_room, alert: I18n.t("room.no_room.invalid_room_uid")
end
redirect_to room_path(@room) redirect_to room_path(@room)
end end

View File

@ -683,7 +683,7 @@ describe RoomsController, type: :controller do
post :join_specific_room, params: { join_room: { url: "abc" } } post :join_specific_room, params: { join_room: { url: "abc" } }
expect(flash[:alert]).to eq(I18n.t("room.no_room.invalid_room_uid")) expect(flash[:alert]).to eq(I18n.t("room.no_room.invalid_room_uid"))
expect(response).to redirect_to room_path(@user.main_room) expect(response).to redirect_to cant_create_rooms_path
end end
it "should redirect the user to the room uid they supplied" do it "should redirect the user to the room uid they supplied" do