FEATURE: Make invites work with existing users (PR #13532)

Users who were already logged in and were given an invite link used to see an error message saying that they already have an account and cannot redeem the invite.

GitHub

Does it works if the topic is only visible to a group that the user was just added to in the same invite? I mean, will the group.add(current_user) already affect the guardian in this line?

I was sure that it worked, but no, it did not because the list of secured categories is cached in the User object. I updated the PR with the fix, added a test and also moved some of the logic out of before_action handler.