Search code examples
apostrophe-cms

ApostropheCMS: Redirect to previous page after login


I'm working on an Intranet and all my Sites are only accessable when the user is logged in. We want to send Newsletters for special News-Releases.

I have the following scenario:

  • Enter the Site through a Newsletter.
  • Link is set to something like www.exampleproject.com/news
  • Since not LoggedIn -> Site redirects to /login
  • Clientside: document.referrer has my previous Pagelink stored
  • After a successful login the user is redirected to / (Home)

So i know that i have the Information i need in my client. But i don't know how and where i should pass it.

Did someone implement something like that already or has a clue about my problem?


Solution

  • This feature is available via the apostrophe-second-chance-login module. When this npm module is installed and configured (per the README), requests for pages that would otherwise 404 due to permissions result in a login prompt followed by a redirect to the page.