Browse Source

feat(auth): implement role assignment for new users during OAuth login

pull/5912/head
Germán Martín 2 months ago
parent
commit
1983f99515
  1. 6
      apps/api/src/app/auth/auth.service.ts

6
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'
}
});
}

Loading…
Cancel
Save