Some advice on the best way to do this - redirect on login based on link clicked

Need some advice on the best and simplest way to implement this for my app.

  1. I have an app which sends out an email.

  2. That email contains a link to a particular page and some parameters to display as certain record from the database - so it may look like this: https://app.example.com/dashbaord?ID=265858n474n4hj

  3. On click of the link if the user is not logged in it will take them to the login page where they log in first.

  4. Once they login they are redirected the url specified above.

The bit I am unsure off is if I the security manager directs them to login and they login how do I cache the link they clicked so they are then redirected to the specified url?

Let me know if the process or question is not clear!

Thank you!

Keep the redirect url in a url query parameter and on success of the login read the parameter and do the redirect.

Ah ok that makes sense.

Cheers!

1 Like

Since you are using NodeJS, you can make use of the server side server connect to handle this.
If you are already using a Server Action for this, you can modify it. If not, just create a new SA.

  1. In the SA for server side server connect, check that if there is a ID in $_PARAM. If it does, save the current URL ($_SERVER.PATH_INFO) in a session variable.
  2. Then, your page level security enforcer redirects the user to login page.
  3. After the security login step, your login SA would check if the redirect session exists. If it does do a set value with that URL & delete session. Else, do a set value with your regular homepage URL.
  4. On client side, in login server connect on:success event, do a browser goto to whatever the returned URL is.
1 Like