refactor: Update user creation logic in UserService
This commit is contained in:
parent
28e42b2248
commit
bc4dcc26ef
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user