# Angular + Nodejs New User flow

**URL:** <https://community.auth0.com/t/angular-nodejs-new-user-flow/92112>\
**Category:** Get Help\
**Tags:** single-page-applicat, create-user, mysql, api, login\
**Created:** [October 10, 2022, 9:01pm UTC](https://community.auth0.com/t/angular-nodejs-new-user-flow/92112 "2022-10-10T21:01:14Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![ty.frith](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/ty.frith/32/58484_2.png) [@ty.frith](https://community.auth0.com/u/ty.frith)\
**Post date:** [October 10, 2022, 11:12pm UTC](https://community.auth0.com/t/angular-nodejs-new-user-flow/92112/4 "2022-10-10T23:12:25Z")

</div>

Hey there @SpencerWF welcome to the community!

These are all great questions! I usually point to our [architectural scenarios](https://auth0.com/docs/get-started/architecture-scenarios/spa-api) documentation first and foremost to serve as high level overview.

1. In an Auth0/OAuth/OIDC context this is all done via [tokens](https://auth0.com/docs/secure/tokens) (ID/Access).

2. Typically, this is added as a custom claim to a user’s ID and/or Access token, something like:

```auto
exports.onExecutePostLogin = async (event, api) => {
  const namespace = 'https://example.com';
    api.accessToken.setCustomClaim(`${namespace}/app_metadata`, event.user.app_metadata);
    api.idToken.setCustomClaim(`${namespace}/app_metadata`, event.user.app_metadata);
//additionally, user metadata
    api.accessToken.setCustomClaim(`${namespace}/user_metadata`, event.user.user_metadata);
    api.idToken.setCustomClaim(`${namespace}/user_metadata`, event.user.user_metadata);
};

```

Some more on [custom claims](https://auth0.com/docs/get-started/apis/scopes/sample-use-cases-scopes-and-claims#add-custom-claims-to-a-token) and [metadata](https://auth0.com/docs/manage-users/user-accounts/metadata/manage-user-metadata).

1. You can certainly go the rule/action route - That is, inspect the user profile on login for some some of reference to your external DB, and if it does not exist then make the necessary calls to your backend.

Alternatively, you could use the ID token returned in the initial authentication exchange to create the user in your DB. Here’s a similar topic which should help:

> [@Best practices for creating users in backend DB on new registrations with Auth0](https://community.auth0.com/t/best-practices-for-creating-users-in-backend-db-on-new-registrations-with-auth0/61185/4):
>
> One question we have is why you would need a call to the management API at all. You should be able to use the ID token returned from the initial authentication to create a user in your DB.

1. You should be able to avoid a call the Management API altogether if you use the ID Token as mentioned previously.

Hopefully this helps clear things up a bit!

---

_[View the full topic](https://community.auth0.com/t/angular-nodejs-new-user-flow/92112)._
