Browse Source

Refactoring

pull/5914/head
Thomas Kaul 2 months ago
parent
commit
531bb269db
  1. 4
      apps/api/src/app/user/user.controller.ts
  2. 17
      apps/api/src/app/user/user.service.ts

4
apps/api/src/app/user/user.controller.ts

@ -126,9 +126,7 @@ export class UserController {
);
}
const { accessToken, id, role } = await this.userService.createUser({
data: {}
});
const { accessToken, id, role } = await this.userService.createUser();
return {
accessToken,

17
apps/api/src/app/user/user.service.ts

@ -526,19 +526,20 @@ export class UserService {
});
}
public async createUser({
data
}: {
data: Prisma.UserCreateInput;
}): Promise<User> {
if (!data?.provider) {
public async createUser(
{
data
}: {
data: Prisma.UserCreateInput;
} = { data: {} }
): Promise<User> {
if (!data.provider) {
data.provider = 'ANONYMOUS';
}
// Check if there's already an admin user
// If not, assign ADMIN role to the first user
if (!data.role) {
const hasAdmin = await this.hasAdmin();
data.role = hasAdmin ? 'USER' : 'ADMIN';
}

Loading…
Cancel
Save