diff --git a/apps/api/src/app/auth/auth.service.ts b/apps/api/src/app/auth/auth.service.ts index a6ee5d260..75661fe98 100644 --- a/apps/api/src/app/auth/auth.service.ts +++ b/apps/api/src/app/auth/auth.service.ts @@ -60,11 +60,15 @@ export class AuthService { throw new Error('Sign up forbidden'); } + // Check if there's already an admin user + const hasAdmin = await this.userService.hasAdmin(); + // Create new user if not found user = await this.userService.createUser({ data: { provider, - thirdPartyId + thirdPartyId, + role: hasAdmin ? 'USER' : 'ADMIN' } }); }