# NextJS - correct place for after auth logic?

**URL:** <https://community.auth0.com/t/nextjs-correct-place-for-after-auth-logic/78061>\
**Category:** Get Help\
**Tags:** react, nextjs\
**Created:** [February 10, 2022, 5:45pm UTC](https://community.auth0.com/t/nextjs-correct-place-for-after-auth-logic/78061 "2022-02-10T17:45:16Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![StaringSkyward](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/staringskyward/32/12776_2.png) [@StaringSkyward](https://community.auth0.com/u/StaringSkyward)\
**Post date:** [February 10, 2022, 5:45pm UTC](https://community.auth0.com/t/nextjs-correct-place-for-after-auth-logic/78061/1 "2022-02-10T17:45:16Z")

</div>

Hey folks.

I have a very simple NextJS SPA which is working great with nextjs-auth0. I now need our users to complete a one-off form after they first authenticate. Until they have done this the only thing they should be able to do is log out.

Should I be performing this check in the global app code and perhaps saving a boolean in the session to indicate that they have completed the form (and therefore prevent it from firing on every request) or is there a better way?

Thanks!

---

<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:** [February 25, 2022, 10:22pm UTC](https://community.auth0.com/t/nextjs-correct-place-for-after-auth-logic/78061/3 "2022-02-25T22:22:24Z")

</div>

Hi @StaringSkyward,

Welcome to the Auth0 Community!

Have you considered building this into a [Redirect with Actions](https://auth0.com/docs/customize/actions/flows-and-triggers/login-flow/redirect-with-actions)?

This approach allows you to integrate the form fill into the auth flow.

Let me know if you have questions.

---

<div class="post-metadata">

**Author:** ![kdesimini](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/kdesimini/32/21577_2.png) [@kdesimini](https://community.auth0.com/u/kdesimini)\
**Post date:** [March 31, 2022, 6:41pm UTC](https://community.auth0.com/t/nextjs-correct-place-for-after-auth-logic/78061/4 "2022-03-31T18:41:09Z")

</div>

Another option is to use the management api and modify the user’s app\_metadata on form submission. Then query the userinfo endpoint to get this data if I remember correctly @dan.woda keep me honest [Get Management API Access Tokens for Single-Page Applications](https://auth0.com/docs/secure/tokens/access-tokens/get-management-api-tokens-for-single-page-applications)

---

<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:** [April 1, 2022, 12:53pm UTC](https://community.auth0.com/t/nextjs-correct-place-for-after-auth-logic/78061/5 "2022-04-01T12:53:41Z")

</div>

@kdesimini,

That is a great thought, and thanks for suggesting it! Unfortunately, a Management API access token that is requested from a SPA does not have the necessary scope for updating a user’s app\_metadata. This is because the application is a client side app and the end user has access to the token, which would allow them to make updates to their own app\_metadata.

Hope that helps!

---

<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:** [April 22, 2022, 12:03am UTC](https://community.auth0.com/t/nextjs-correct-place-for-after-auth-logic/78061/6 "2022-04-22T00:03:56Z")

</div>


