From 8301a5e73870581e499ba92f82802618ec113c86 Mon Sep 17 00:00:00 2001 From: Paul Walko Date: Sun, 7 Dec 2025 17:47:34 -0700 Subject: [PATCH] get user roles --- web/README.md | 6 +++++- web/src/lib/auth0.ts | 14 ++++++++++++-- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/web/README.md b/web/README.md index c16a8c7..e5ac14c 100644 --- a/web/README.md +++ b/web/README.md @@ -1,5 +1,9 @@ # CopilotKit <> LangGraph Starter +### Referenes +https://github.com/auth0/nextjs-auth0/blob/main/EXAMPLES.md + + This is a starter template for building AI agents using [LangGraph](https://www.langchain.com/langgraph) and [CopilotKit](https://copilotkit.ai). It provides a modern Next.js application with an integrated LangGraph agent to be built on top of. ## Prerequisites @@ -102,4 +106,4 @@ If you see "I'm having trouble connecting to my tools", make sure: If you encounter Python import errors: ```bash npm install:agent -``` \ No newline at end of file +``` diff --git a/web/src/lib/auth0.ts b/web/src/lib/auth0.ts index 6aeef7c..90d3ebd 100644 --- a/web/src/lib/auth0.ts +++ b/web/src/lib/auth0.ts @@ -1,3 +1,13 @@ -import { Auth0Client } from '@auth0/nextjs-auth0/server'; +import { Auth0Client, filterDefaultIdTokenClaims } from '@auth0/nextjs-auth0/server'; -export const auth0 = new Auth0Client(); +export const auth0 = new Auth0Client({ + async beforeSessionSaved(session, idToken) { + return { + ...session, + user: { + ...filterDefaultIdTokenClaims(session.user), + roles: session.user['https://chat.caving.dev/roles'] + } + }; + } +});