refactor: Update user creation logic in UserService

This commit is contained in:
M1000fr 2024-12-12 16:57:28 +01:00
parent 28e42b2248
commit bc4dcc26ef

View File

@ -59,13 +59,17 @@ export class UserService {
},
});
if (!user)
if (!user) {
const isFirstUser = (await this.prisma.user.count()) === 0;
user = await this.prisma.user.create({
data: {
providerId,
username,
providerId,
role: isFirstUser ? "ADMIN" : "STUDENT",
},
});
}
return user;
}