Reverts the temporary fix (8e4fea897e68e4b50e548f820dc1f1fdeeeb199d) and restores the feature introduced in e638d43f0a7549a75eb9de57bb8508b36f11543d.
The issue that was the reason for the revert (https://meta.discourse.org/t/logins-redirects-to-missing-notifications-page/149718) was a combination of two bugs:
- Fixed in this commit - the click listener was accidentally registered also for logged-out users. This meant that the first click on a page always trigger an AJAX call to the notifications endpoint (
/notifications?recent=true&limit=5), which returned a 403 error. Now, this code is run only when the user is logged in.
- A still unknown bug that I could not reproduce, which was somehow setting the login redirect cookie to the URL of that previously failed AJAX request.