# Ensure pre-user-registration hook fires after entering email with Identifier First

**URL:** <https://community.auth0.com/t/ensure-pre-user-registration-hook-fires-after-entering-email-with-identifier-first/150414>\
**Category:** Get Help\
**Tags:** identifier-first, login-experience\
**Created:** [October 24, 2024, 1:52pm UTC](https://community.auth0.com/t/ensure-pre-user-registration-hook-fires-after-entering-email-with-identifier-first/150414 "2024-10-24T13:52:44Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![mwhite](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/mwhite/32/61675_2.png) [@mwhite](https://community.auth0.com/u/mwhite)\
**Post date:** [October 24, 2024, 1:52pm UTC](https://community.auth0.com/t/ensure-pre-user-registration-hook-fires-after-entering-email-with-identifier-first/150414/1 "2024-10-24T13:52:44Z")

</div>

I have Identifier first set up for our app. It has been using Username-Password-Authentication so far. In addition to adding passwordless email logins, we wanted to redirect the user to an external site if their account hasn’t been migrated in our system yet.

This means that after they enter their email, we want to redirect them to a known external page.

I’ve tried using the pre-user-registration trigger, but that doesn’t seem to run on the login page. Only when I test the passwordless email login.

---

<div class="post-metadata">

**Author:** ![rueben.tiow](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/rueben.tiow/32/11646_2.png) [@rueben.tiow](https://community.auth0.com/u/rueben.tiow)\
**Post date:** [October 24, 2024, 5:52pm UTC](https://community.auth0.com/t/ensure-pre-user-registration-hook-fires-after-entering-email-with-identifier-first/150414/3 "2024-10-24T17:52:33Z")

</div>

Hi @mwhite,

Welcome to the Auth0 Community!

You could use a Post-Login action script to redirect your users to an external page after they log in. Check out our [Redirect with Actions](https://auth0.com/docs/customize/actions/explore-triggers/signup-and-login-triggers/login-trigger/redirect-with-actions) documentation.

Let me know if you have any questions.

Thanks,  
Rueben

---

<div class="post-metadata">

**Author:** ![mwhite](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/mwhite/32/61675_2.png) [@mwhite](https://community.auth0.com/u/mwhite)\
**Post date:** [October 25, 2024, 2:33pm UTC](https://community.auth0.com/t/ensure-pre-user-registration-hook-fires-after-entering-email-with-identifier-first/150414/4 "2024-10-25T14:33:27Z")

</div>

This would need to be before they log in, as they would not yet have an account on auth0, and thus cannot provide a valid username/password combo to get to that trigger.

---

<div class="post-metadata">

**Author:** ![rueben.tiow](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/rueben.tiow/32/11646_2.png) [@rueben.tiow](https://community.auth0.com/u/rueben.tiow)\
**Post date:** [October 25, 2024, 4:27pm UTC](https://community.auth0.com/t/ensure-pre-user-registration-hook-fires-after-entering-email-with-identifier-first/150414/5 "2024-10-25T16:27:35Z")

</div>

Hi @mwhite,

Thanks for the clarification.

The pre-user registration action only triggers during a signup event, not a login attempt. Therefore, when a user enters their email on the login page through Identifier First, the pre-user registration action script will not execute. Additionally, redirecting in Actions is only supported in post-login flows.

As a workaround, you could use a post-login action to check whether the user has migrated to your system and then perform a conditional redirect.

For example:

```auto
exports.onExecutePostLogin = async (event, api) => {
  if (event.user.app_metadata && !event.user.app_metadata.migrated) {
    api.redirect.sendUserTo("https://my-app.exampleco.com");
  }
};
exports.onContinuePostLogin = async (event, api) => {
  api.user.setAppMetadata("migrated",true)
}

```

Thanks,  
Rueben

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/auth0/original/3X/b/5/b560f266932fcce5d57f09a6595bd50518cae3f3.jpeg) [@system](https://community.auth0.com/u/system)\
**Post date:** [November 8, 2024, 4:28pm UTC](https://community.auth0.com/t/ensure-pre-user-registration-hook-fires-after-entering-email-with-identifier-first/150414/6 "2024-11-08T16:28:11Z")

</div>

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