Change ctx.session.user values to include new ones? Bad idea?
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:Jump to 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";
...
2 Replies
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";
declare module "next-auth" {
interface Session {
user?: {
id: string;
role: Role
} & DefaultSession["user"];
}
interface User {
id: string;
role: Role;
// ...other properties
}
}
@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.