# How to update session after changing a user's role

**URL:** <https://community.auth0.com/t/how-to-update-session-after-changing-a-users-role/97994>\
**Category:** Get Help\
**Tags:** authentication-sessions, sessions\
**Created:** [January 12, 2023, 12:32am UTC](https://community.auth0.com/t/how-to-update-session-after-changing-a-users-role/97994 "2023-01-12T00:32:00Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![faabiopk](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/faabiopk/32/40579_2.png) [@faabiopk](https://community.auth0.com/u/faabiopk)\
**Post date:** [January 12, 2023, 12:32am UTC](https://community.auth0.com/t/how-to-update-session-after-changing-a-users-role/97994/1 "2023-01-12T00:32:00Z")

</div>

Hello again,

I am facing issues keeping my auth0 user in sync with the session in my NextJS application. Basically I need the user’s role and permissions to be updated when I add/remove a role or permission.

Right now I am using a role to conditionally render some pages, but after giving the user said role, the sessions in frontend (with useUser) and backend (with getSession) are unchanged. Roles and permissions are added as custom claims via Login actions.

Two questions:

1. Can I “force” update the session to see the custom claims of roles and permissions reflected?
2. Is there a better alternative for always keeping roles & permission in sync with my changes on the auth0 dashboard?

Right now I have to logout and login again to see any modifications.

Thank you.  
Fabio

---

<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:** [January 12, 2023, 12:47am UTC](https://community.auth0.com/t/how-to-update-session-after-changing-a-users-role/97994/3 "2023-01-12T00:47:01Z")

</div>

Hey @faabiopk!

Thanks for the detailed description.

> [@faabiopk](#):
>
> Right now I have to logout and login again to see any modifications.

As far as I’m aware this is the only way to get the new role/permission added - Have you by any chance explored using silent auth?

> **[Configure Silent Authentication](https://auth0.com/docs/authenticate/login/configure-silent-authentication)**
>
> Learn how to keep users logged in to your application using silent authentication.

---

<div class="post-metadata">

**Author:** ![faabiopk](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/faabiopk/32/40579_2.png) [@faabiopk](https://community.auth0.com/u/faabiopk)\
**Post date:** [January 12, 2023, 1:05am UTC](https://community.auth0.com/t/how-to-update-session-after-changing-a-users-role/97994/4 "2023-01-12T01:05:55Z")

</div>

Thanks for the response @ty.frith!

I checked this page before, but it was unclear to me where/how should I use the silent authentication step.

Should I do something like this inside my endpoints?

```auto
export default withApiAuthRequired(async function myApiRoute(req, res) {

    await handleLogin(req, res, {
      authorizationParams: {
        prompt: 'none',
        audience: "mysite.com"
      },
    });

}

```

Using this redirects me immediately.  
Is there a way of “re-authorizing” the user and continue on the same page?

Thanks 🙂

---

<div class="post-metadata">

**Author:** ![imad](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/imad/32/34807_2.png) [@imad](https://community.auth0.com/u/imad)\
**Post date:** [January 22, 2023, 3:16pm UTC](https://community.auth0.com/t/how-to-update-session-after-changing-a-users-role/97994/5 "2023-01-22T15:16:08Z")

</div>

Have you by any chance managed to resolve this issue?

---

<div class="post-metadata">

**Author:** ![faabiopk](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/faabiopk/32/40579_2.png) [@faabiopk](https://community.auth0.com/u/faabiopk)\
**Post date:** [January 23, 2023, 1:27pm UTC](https://community.auth0.com/t/how-to-update-session-after-changing-a-users-role/97994/6 "2023-01-23T13:27:59Z")

</div>

Using silent auth solved most of my problems. It is not automatic, but I believe you could make it so.

Silent auth basically solves the problem in the #1 way I described in my question.

---

<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:** [February 6, 2023, 1:28pm UTC](https://community.auth0.com/t/how-to-update-session-after-changing-a-users-role/97994/7 "2023-02-06T13:28:31Z")

</div>

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