Custom Action to redirect, redirects to early


I am attempting to get the login page to redirect to http://localhost:3000/admin instead of http://localhost:3000 after authentication is completed.

I read this post which says you can do that with Actions

However, after implementing it, the flow will redirect the user back to the website before completing the authentication.

This is what I did:

  1. create a custom action with the trigger “Login / Post login”
  2. pasted in the code provided in the link above with my own URL
  3. went to Flow > Login, and put the custom action in the flow.

Could there be something I did wrong, Or is there a better method?

(also i have no clue how the tagging system works so sorry for weir tags)

Hi @Ralkey

Welcome to the Auth0 Community.

The redirect using Actions is more of a temporary redirect to perform some additional actions as part of the authentication flow and by design you’re expected to return to the Action to complete the authentication. It may not be a suitable fit for your use case. There would be a better way, I’m assuming by default after authentication you come back to http://localhost:3000 as an authenticated user (providing the auth was successful).

If you want to redirect the user to a specific url post authentication and it’s static url i.e. it’s always going to be the same for every user you could just bake that into your application e.g. I have a dot net application which is a regular web app. My callback is https://localhost:5001/callback which is handled by the middleware and I return to https://localhost:5001 by default post successful authentication.

I can redirect somewhere else within my app like this:

public async Task Login(string returnUrl = "/Account/UserProfile")
    await HttpContext.ChallengeAsync("Auth0", new AuthenticationProperties() { RedirectUri = returnUrl });

There may be something similar you can do via the SDK that you’re using.

If you need some flexibility you can take this approach and use the state parameter

I hope this helps.
Warm regards.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.