Change ctx.session.user values to include new ones? Bad idea?

DDebaucus5/31/2023
Right now when using ctx.session.user I get a few default options that come with t3-app. .id, .name?, .image? and .email?. Is there a way to change this to include new values? I can't find an obvious spot or I am being silly.
Solution:
You can do this in your auth.ts where the next-auth module is extended. Make sure you don't add anything sensitive when extending. ``` import type { Role } from "@prisma/client"; import { DefaultSession } from "next-auth"; ...
Jump to solution
Solution
TTobyMcCann5/31/2023
You can do this in your auth.ts where the next-auth module is extended. Make sure you don't add anything sensitive when extending. ``` import type { Role } from "@prisma/client"; import { DefaultSession } from "next-auth"; declare module "next-auth" { interface Session { user?: { id: string; role: Role } & DefaultSession["user"]; } interface User { id: string; role: Role; // ...other properties } }
DDebaucus6/1/2023
@TobyMcCann Thank you! Additionally, I had to add it to my callbacks: []in order for it to function as I wanted, but it is now working.

Looking for more? Join the community!

Want results from more Discord servers?
Add your server
Recommended Posts