Skip to content

Commit

Permalink
fix(core): Fix permissions error on creation of superadmin
Browse files Browse the repository at this point in the history
Relates to #2492, relates to #2478
  • Loading branch information
michaelbromley committed Jan 15, 2024
1 parent fc5d981 commit 3e4e31c
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions packages/core/src/service/services/administrator.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { In, IsNull } from 'typeorm';
import { RequestContext } from '../../api/common/request-context';
import { RelationPaths } from '../../api/index';
import { EntityNotFoundError, InternalServerError, UserInputError } from '../../common/error/errors';
import { idsAreEqual, normalizeEmailAddress } from '../../common/index';
import { assertFound, idsAreEqual, normalizeEmailAddress } from '../../common/index';
import { ListQueryOptions } from '../../common/types/common-types';
import { ConfigService } from '../../config';
import { TransactionalConnection } from '../../connection/transactional-connection';
Expand Down Expand Up @@ -317,10 +317,10 @@ export class AdministratorService {
superadminCredentials.identifier,
superadminCredentials.password,
);
const createdAdministrator = await this.connection
.getRepository(ctx, Administrator)
.save(administrator);
await this.assignRole(ctx, createdAdministrator.id, superAdminRole.id);
const { id } = await this.connection.getRepository(ctx, Administrator).save(administrator);
const createdAdministrator = await assertFound(this.findOne(ctx, id));
createdAdministrator.user.roles.push(superAdminRole);
await this.connection.getRepository(ctx, User).save(createdAdministrator.user, { reload: false });
} else {
const superAdministrator = await this.connection.rawConnection
.getRepository(Administrator)
Expand Down

0 comments on commit 3e4e31c

Please sign in to comment.