# Redirect on signup to "Create Profile" Page

**URL:** <https://community.auth0.com/t/redirect-on-signup-to-create-profile-page/51071>\
**Category:** Get Help\
**Tags:** redirect-rules, login\
**Created:** [October 6, 2020, 5:22am UTC](https://community.auth0.com/t/redirect-on-signup-to-create-profile-page/51071 "2020-10-06T05:22:24Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![devajain](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/devajain/32/12814_2.png) [@devajain](https://community.auth0.com/u/devajain)\
**Post date:** [October 6, 2020, 5:22am UTC](https://community.auth0.com/t/redirect-on-signup-to-create-profile-page/51071/1 "2020-10-06T05:22:24Z")

</div>

Hi,

I am trying to redirect users to a “Create Profile” page after their sign up. I have created a rule that checks the login count through following rule.

```auto
function (user, context, callback) {
  var count = context.stats && context.stats.loginsCount ? context.stats.loginsCount : 0;
  if (count === 1) {
    context.redirect = {
      url: "http://localhost:3000/capture-details"
    };
    return callback(null, user, context);
  }
  else {
        context.redirect = {
      url: "http://localhost:3000"
    };
    return callback(null, user, context);
   }
  
}

```

Now this does redirect properly, but after sign up the page keeps reloading for reasons I can’t think of.  
Is there something wrong with the rule that I have created?

---

<div class="post-metadata">

**Author:** ![dan.woda](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dan.woda/32/18340_2.png) [@dan.woda](https://community.auth0.com/u/dan.woda)\
**Post date:** [October 6, 2020, 9:15pm UTC](https://community.auth0.com/t/redirect-on-signup-to-create-profile-page/51071/3 "2020-10-06T21:15:21Z")

</div>

Hi @devajain,

Welcome to the Community!

I would guess that this redirect rule is being run again, which could cause some issues. Using a flag on the user’s app\_metadata may be better than login count.

This doc may be helpful:

> **[Rules Execution Best Practices](https://auth0.com/docs/customize/rules/rules-best-practices/rules-execution-best-practices)**
>
> Learn about best practices for executing Auth0 rules.

---

<div class="post-metadata">

**Author:** ![devajain](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/devajain/32/12814_2.png) [@devajain](https://community.auth0.com/u/devajain)\
**Post date:** [October 11, 2020, 3:37am UTC](https://community.auth0.com/t/redirect-on-signup-to-create-profile-page/51071/4 "2020-10-11T03:37:37Z")

</div>

Hi Dan,

Thank you for your response.

```auto
function (user, context, callback) {
  user.user_metadata = user.user_metadata || {};
  console.log(user.user_metadata.createdProfile);
  if (user.user_metadata.createdProfile === true) {
    context.redirect = {
      url: "http://localhost:3000"
    };
  }
  else {
        context.redirect = {
      url: "http://localhost:3000/capture-details"
    };
    
  }
  return callback(null, user, context);
  
}

```

So, I am updating the user\_metadata with a field “createdProfile: true” and using this rule to redirect to another page if the profile on my database is already created and I am still facing the same issue. (page keeps reloading)

Is there something wrong with the rule?

---

<div class="post-metadata">

**Author:** ![dan.woda](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dan.woda/32/18340_2.png) [@dan.woda](https://community.auth0.com/u/dan.woda)\
**Post date:** [October 12, 2020, 9:23pm UTC](https://community.auth0.com/t/redirect-on-signup-to-create-profile-page/51071/5 "2020-10-12T21:23:32Z")

</div>

It sounds like you are redirecting from this rule and never resuming the rules flow.

`Context.redirect` allows you to redirect _mid-authentication_, and expects you to redirect back after collecting whatever information, and resume the auth flow.

Are you redirecting and never resuming authentication?

> **[Redirect Users from Within Rules](https://auth0.com/docs/customize/rules/redirect-users)**
>
> Learn how to customize authentication flows by redirecting users using rules. Example areas that can be customized include MFA, privacy policy acceptance, and gathering user data.

---

<div class="post-metadata">

**Author:** ![devajain](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/devajain/32/12814_2.png) [@devajain](https://community.auth0.com/u/devajain)\
**Post date:** [October 12, 2020, 9:29pm UTC](https://community.auth0.com/t/redirect-on-signup-to-create-profile-page/51071/6 "2020-10-12T21:29:54Z")

</div>

> [@dan.woda](#):
>
> redirecting and never resuming authentication

Yes I wish to redirect and never resume authentication

---

<div class="post-metadata">

**Author:** ![dan.woda](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dan.woda/32/18340_2.png) [@dan.woda](https://community.auth0.com/u/dan.woda)\
**Post date:** [October 13, 2020, 7:01pm UTC](https://community.auth0.com/t/redirect-on-signup-to-create-profile-page/51071/7 "2020-10-13T19:01:28Z")

</div>

The redirect that occurs after authentication is determined by the redirect\_uri that is sent during the initial request (from your application).

Many of our customers choose to do a redirect within a rule, just like you are doing, to collect this type of information. The advantage of using a rule is the fact that your can require the information is received before granting access, making the process mandatory. All you have to do is resume authentication after the fact. The first doc I linked lays out how to resume authentication.

---

<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:** [October 28, 2020, 7:01pm UTC](https://community.auth0.com/t/redirect-on-signup-to-create-profile-page/51071/8 "2020-10-28T19:01:30Z")

</div>

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