FIX: Do not redirect to a topic user cannot see (PR #13550)

Inviting a user to a private topic used to redirect them to a 404 page immediately after signup.

GitHub

      fab!(:invite) { Fabricate(:invite, email: 'test@example.com') }
      fab!(:secured_category) do

Is there a reason we need to fetch the user record from the database here?

Ditto: FIX: Do not redirect to a topic user cannot see by udan11 · Pull Request #13550 · discourse/discourse · GitHub

Ditto: FIX: Do not redirect to a topic user cannot see by udan11 · Pull Request #13550 · discourse/discourse · GitHub

Is this because the topic’s permission changed after the invite has been sent? Seems strange the we don’t give the user permission to view the topic when the user has been invited from the topic.

It is possible to invite a user to a topic they cannot see.

The most obvious case is when you invite a user to a topic that only a group can see, but you do not invite the user to that group too. I am handling this by adding a warning in a different PR.

Then, there are the most complex cases when the topic is moved or permissions change and if the user redeems the invite later then they were welcomed by a 404 page.

So where does the invitee get sent to, then? The homepage as though no topic had been specified?