Redirect after login complete

Hello,

I’m trying to redirect users after the login is complete with universal login.

What I mean is that I found how to do that with actions (post login trigger), but at that point the user is not authenticated yet.
I need access to the user_id post login, so the redirect before /continue is not working for that.

Unless I’m misunderstanding how the flow works :confused:

Any help would be appreciated.

Hi Gianpiero,
You could use a Post Login Action

1 Like

Hello @gianpiero.puleo,

Welcome to the Auth0 community!

The Login Trigger executes when a user successfully authenticates against an application on an Auth0 tenant. This also includes post-signup authentication.

I understand that you need to access to the user_id. You can access it with event.user.user_id. Feel free to check out the docs on the Event object. It provides information about the user logging in. Actions Triggers: post-login - Event Object

I am sharing this documentation that explains the Login Trigger in more detail: Login Trigger

I hope this was helpful and if anything is unclear, don’t hesitate to come back with more questions.

Thanks,
Tudor

Thank you Tudor, if I understand your answer, that’s not what I’m asking for.

If I get your point, I’m aware I can access event.user.user_id, but at that point I’m still in the post-login script.

My need is, after the whole process is complete, to redirect the user to a different webpage on my website.
The only way I found so far is with api.redirect.sendUserTo("/my/web/page") but when it does that, the authentication is not over yet.

Ok, I found the answer. Sometimes you just need to sleep on it :slight_smile:

export const GET = handleAuth({
  login: handleLogin({
    returnTo: "/api/callbacks/signin",
  }),
  signup: handleLogin({
    returnTo: "/api/callbacks/signup",
    authorizationParams: { screen_hint: "signup" },
  }),
});
1 Like

I’m glad you managed to find a solution for your problem.

Also, thank you for sharing it with the community.

In the case you have any additional question, please come back to the community.

Thanks,
Tudor

1 Like

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