Skip to content

Commit 43b58eb

Browse files
fix
1 parent 272d2d9 commit 43b58eb

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

EXAMPLES.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -621,27 +621,27 @@ The `beforeSessionSaved` hook is run right before the session is persisted. It p
621621
The hook recieves a `SessionData` object and an ID token. The function must return a Promise that resolves to a `SessionData` object: `(session: SessionData) => Promise<SessionData>`. For example:
622622

623623
```ts
624-
import { Auth0Client, filterClaims } from "@auth0/nextjs-auth0/server"
624+
import { Auth0Client, filterDefaultIdTokenClaims } from "@auth0/nextjs-auth0/server"
625625

626626
export const auth0 = new Auth0Client({
627627
async beforeSessionSaved(session, idToken) {
628628
return {
629629
...session,
630630
user: {
631-
...filterClaims(session.user),
631+
...filterDefaultIdTokenClaims(session.user),
632632
foo: session.user.foo, // keep the foo claim
633633
},
634634
}
635635
},
636636
})
637637
```
638638

639-
The `session.user` object passed to the `beforeSessionSaved` hook will contain every claim in the ID Token, including custom claims. You can use the `filterClaims` utility to filter out the standard claims and only keep the custom claims you want to persist.
639+
The `session.user` object passed to the `beforeSessionSaved` hook will contain every claim in the ID Token, including custom claims. You can use the `filterDefaultIdTokenClaims` utility to filter out the standard claims and only keep the custom claims you want to persist.
640640

641641
Alternatively, you can use the entire `session.user` object if you would like to include every claim in the ID Token by just returning the `session` like so:
642642

643643
```ts
644-
import { Auth0Client, filterClaims } from "@auth0/nextjs-auth0/server"
644+
import { Auth0Client } from "@auth0/nextjs-auth0/server"
645645

646646
export const auth0 = new Auth0Client({
647647
async beforeSessionSaved(session, idToken) {

0 commit comments

Comments
 (0)