Working on role in workspace.

This commit is contained in:
charles-gauthereau
2024-12-31 10:54:18 +01:00
parent e1a7ca8558
commit 6f75079a40
29 changed files with 464 additions and 124 deletions
+10 -6
View File
@@ -117,14 +117,18 @@ export const {handlers, auth: baseAuth, signIn, signOut} = NextAuth({
const defaultOrganization = await prisma.organization.findUnique({
where: {slug: "default"},
include: {users: {}}
});
await prisma.userOrganization.create({
data: {
userId: newUser.id,
organizationId: defaultOrganization.id
},
});
const organizationRole = defaultOrganization.users.length > 0 ? "member" : "admin"
await prisma.userOrganization.create({
data: {
userId: newUser.id,
organizationId: defaultOrganization.id,
role: organizationRole
},
});
return role !== "pending";