Redirect After Login

Hi @Brandon_Cannaday coming back to this a while later, is there a easier/more dynamic way to allow the login to redirect to any page after login in completion with out having to put the


redirect path explicitly in each pages redirect path.
Id like it to work out right to any page, after you long in, but having to remember to put the redirect in each new pages sounds like an easy way to have mistakes.

Experiences do support version-wide unauthorized handlers:

You can find this by clicking the Edit main navigation menu → the three dots in the top-right corner → Version Settings.

You can provide a template there that sends the user to /login and appends the user’s current page and query parameters to a redirect parameter.

The template is:

/login?redirect={{encodeURIComponent request.path}}%3F{{encodeURIComponent (queryStringEncode request.query)}}

Then, you can configure each endpoint to use the Version’s default “Unauthorized” reply:

To summarize:

  1. Configure the default unauthorized behavior that can be applied to every endpoint in your experience.
  2. Update all existing endpoints to use the new default behavior.
  3. All new endpoints automatically use the version default, so you’ll never have to remember to add this behavior in the future.
1 Like

Great! I will have to manually set each endpoints redirect to use default? is there a way to make sure this is always the default for new endpoints

You’ll have to update your existing endpoints. There’s nothing you have to do for new endpoints. Using the version-wide unauthorized handler is the default setting for new endpoints.

1 Like

Probably spent more time building this trying to figure out how to escape {{ }} in a string than it would’ve took to do it manually but, I was able to mass update every endpoint via this setup using the API node.


Then loop over the resulting endpoints using their id

and use this json as the patch

{
    "unauthorizedReply": {
        "type": "redirect",
        "value": "/login?redirect=\u007B\u007BencodeURIComponent request.path\u007D\u007D%3F\u007B\u007BencodeURIComponent (queryStringEncode request.query)\u007D\u007D"
    }
}

To escape curly braces in templates, you use a leading backslash:

{
  "path": "/devices/\{{hello}}"
}

However, what you’re doing is updating every endpoint to have its own redirect configuration. If you want to use the version default, you need instead set unauthorizedReply to null:

{
  "unauthorizedReply": null
}

That will remove the endpoint-specific behavior, which causes it to fall back to the version default behavior.

1 Like