Skip to content

Commit

Permalink
Fix room redirect not working for legacy links (#5293)
Browse files Browse the repository at this point in the history
  • Loading branch information
farhatahmad authored Jun 28, 2023
1 parent 689e764 commit f862678
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/controllers/external_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def create_user

redirect_location = cookies.delete(:location)

return redirect_to redirect_location, allow_other_host: false if redirect_location&.match?('\/rooms\/\w{3}-\w{3}-\w{3}-\w{3}\/join\z')
return redirect_to redirect_location, allow_other_host: false if redirect_location&.match?('\/rooms\/\w{3}-\w{3}-\w{3}(-\w{3})?\/join\z')

redirect_to root_path
rescue ActionController::Redirecting::UnsafeRedirectError => e
Expand Down
12 changes: 12 additions & 0 deletions spec/controllers/external_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,18 @@
expect(response).to redirect_to('/rooms/o5g-hvb-s44-p5t/join')
end

it 'redirects to the location cookie if its a legacy url (3 sections in uid)' do
request.env['omniauth.auth'] = OmniAuth.config.mock_auth[:openid_connect]

cookies[:location] = {
value: '/rooms/o5g-hvb-s44/join',
path: '/'
}
get :create_user, params: { provider: 'openid_connect' }

expect(response).to redirect_to('/rooms/o5g-hvb-s44/join')
end

it 'redirects to the location cookie if a relative redirection 2' do
request.env['omniauth.auth'] = OmniAuth.config.mock_auth[:openid_connect]

Expand Down

0 comments on commit f862678

Please sign in to comment.