# Running Rule Only Once at Sign Up

**URL:** <https://community.auth0.com/t/running-rule-only-once-at-sign-up/19401>\
**Category:** Get Help\
**Tags:** rules\
**Created:** [December 27, 2018, 8:32am UTC](https://community.auth0.com/t/running-rule-only-once-at-sign-up/19401 "2018-12-27T08:32:47Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![picosam](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/picosam/32/5412_2.png) [@picosam](https://community.auth0.com/u/picosam)\
**Post date:** [December 27, 2018, 8:32am UTC](https://community.auth0.com/t/running-rule-only-once-at-sign-up/19401/1 "2018-12-27T08:32:47Z")

</div>

Hello,

I’m trying to call my backend API once to create a user when they have signed up. I created a rule that checks for `loginCount === 1` as advised. The problem is, when using the React sample [here](https://github.com/auth0-samples/auth0-react-samples/tree/master/01-Login/src) the rule always gets called twice. In the logs, I do indeed see “Success Signup” followed by “Success Login”. In both cases, `loginCount` is 1 and the `context` is identical.

Needless to say, my servers throws an error at the second call. Any ideas how to prevent the second one from calling my server? In fact, why isn’t `loginCount` equal to 0 on “Success Signup”?

Thank you,  
Sammy

---

<div class="post-metadata">

**Author:** ![markd](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/markd/32/38919_2.png) [@markd](https://community.auth0.com/u/markd)\
**Post date:** [December 27, 2018, 2:38pm UTC](https://community.auth0.com/t/running-rule-only-once-at-sign-up/19401/2 "2018-12-27T14:38:01Z")

</div>

Hello @picosam The user is actually logged in when they sign up, which is why you are seeing `loginCount === 1`. I would suggest adding your own attribute to [`app_metadata`](https://auth0.com/docs/rules/guides/metadata) to act as a flag. Your rule checks and sets the flag attribute:

```auto
{ 'app_metadata': {
  'my_flag_attribute': false
  }
}

```

Your rule will trigger when `my_flag_attribute === false`, do whatever processing it needs to do, then set `my_flag_attribute === true`.

---

<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:** [August 28, 2019, 2:56pm UTC](https://community.auth0.com/t/running-rule-only-once-at-sign-up/19401/3 "2019-08-28T14:56:46Z")

</div>

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