Hello Nik
exports.onExecutePostLogin = async (event, api) => {
const namespace = "https://auth.myapp.local";
console.log("Authorization object:", JSON.stringify(event.authorization, null, 2));
if (event.authorization && event.authorization.roles) {
console.log("Roles found:", event.authorization.roles);
api.idToken.setCustomClaim(`${namespace}/roles`, event.authorization.roles);
api.accessToken.setCustomClaim(`${namespace}/roles`, event.authorization.roles);
} else {
console.log("No roles found");
}
};
this is my screenshot of the Trigger Action Log
I do not see this in the front end session
// app/layout.tsx
import { auth0 } from "@/lib/auth0";
import { Inter } from "next/font/google";
import "@/css/satoshi.css";
import "@/css/style.css";
import "react-toastify/dist/ReactToastify.css";
import { redirect } from "next/navigation";
import ToastContainerClientWrapper from "./components/Wrapper/ToastContainerClientWrapper";
import QueryWrapper from "@/components/QueryWrapper/QueryWrapper";
const inter = Inter({ subsets: ["latin"] });
export default async function RootLayout({
children,
}: {
children: React.ReactNode;
}) {
const session = await auth0.getSession();
if (!session?.user) {
// Redirect to the login page if the user is not authenticated
redirect("/auth/login?prompt=consent");
}
return (
<html lang="en">
<body className={inter.className}>
{/* add the query wrapper here */}
<QueryWrapper>
<ToastContainerClientWrapper />
{children}
</QueryWrapper>
</body>
</html>
);
}