Prisma nexth-auth role based access control model

Hi, just getting started with the t3-stack and prisma. I'm a little confused on why the Account model is required for next-auth. Also, I'm not sure how to add a role that would give me type definitions when using the session. Yes, I did looked it up and I followed the tutorial from next-auth, but that doesn't give me the type definitions on the user when setting up the session. https://next-auth.js.org/tutorials/role-based-login-strategy Also, I've already changed the next-auth.d.ts file to include the role.
declare module "next-auth" {
/**
* Returned by `useSession`, `getSession` and received as a prop on the `SessionProvider` React Context
*/
interface Session {
user?: {
id: string;
role: string;
} & DefaultSession["user"];
}
}
declare module "next-auth" {
/**
* Returned by `useSession`, `getSession` and received as a prop on the `SessionProvider` React Context
*/
interface Session {
user?: {
id: string;
role: string;
} & DefaultSession["user"];
}
}
Edit-1: Add next-auth types info;
role-based-login-strategy | NextAuth.js
To add role based authentication to your application, you must do three things.
2 Replies
Kseikyo
Kseikyo3y ago
Fixed by updating next-auth.d.ts
declare module "next-auth" {
/**
* Returned by `useSession`, `getSession` and received as a prop on the `SessionProvider` React Context
*/
interface Session {
user?: {
id: string;
role: string;
} & DefaultSession["user"];
}
interface User extends DefaultUser {
role: string;
}
}
declare module "next-auth" {
/**
* Returned by `useSession`, `getSession` and received as a prop on the `SessionProvider` React Context
*/
interface Session {
user?: {
id: string;
role: string;
} & DefaultSession["user"];
}
interface User extends DefaultUser {
role: string;
}
}
arete
arete2y ago
and you add to [...nextauth].ts callback? thanks!
Want results from more Discord servers?
Add your server