mirror of
https://github.com/massbug/judge4c.git
synced 2025-05-18 15:26:33 +00:00
feat(auth): add event to assign ADMIN role to the first user
This commit is contained in:
parent
b55ed07004
commit
e25a97d698
@ -87,4 +87,15 @@ export const { auth, handlers, signIn, signOut } = NextAuth({
|
|||||||
return encode(params); // Default encoding for JWT
|
return encode(params); // Default encoding for JWT
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
events: {
|
||||||
|
async createUser({ user }) {
|
||||||
|
const count = await prisma.user.count();
|
||||||
|
if (count === 1) {
|
||||||
|
await prisma.user.update({
|
||||||
|
where: { id: user.id },
|
||||||
|
data: { role: "ADMIN" },
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user