[Solved] Error: Authorization Required

I have quite a few experience endpoints defined with various experience dashboard pages. There is a separate work flow backing each of them such as this example:

image

Each dashboard access control is set to Private.

If a user is not logged in and attempts to access one of the endpoints, I set a static response to redirect them to the generic /login page. The login page is backed by a login workflow from the bootstrap example. What i’d ideally like to do is redirect them back to the URL they requested, after they have completed the login step.

I was wondering if there is a global way of doing this redirect while preserving the requested URL?

Hi Paul,

Unfortunately, there is no global way to set this. But whenever you are doing a static reply and want to redirect to the previous path, you can put in the redirect path template as /login?redirect={{request.path}} and that will handle the redirect once the user has authenticated.

Hope that helps,
Erin

Thanks @Erin_Thompson

That looks like it will work for me. Will I need to pickup the query parameter from the payload in the login workflow? I still need to handle both cases: a) redirect to a default root page if there is no previous path or b) redirect to the previous URL if path is provided.

Hey Paul,

Yes in your workflow, on your Endpoint Reply Node, on the URL Template field under the Reply Section, if you put {{#if data.query.redirect}}{{data.query.redirect}}{{else}}/myHomePath{{/if}} then you will be able to redirect them back to where they were or to your home page.

Hope that helps,
Erin

That worked great. Thank you!