Skip to content

Commit 91d299c

Browse files
committed
Fixed IOT-1425 - Bad Request ved første login med KOMBIT bruger
1 parent 0300c79 commit 91d299c

File tree

2 files changed

+5
-7
lines changed

2 files changed

+5
-7
lines changed

src/controllers/user-management/new-kombit-creation.controller.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,8 @@ export class NewKombitCreationController {
6666
);
6767

6868
if (!dbUser.email) {
69-
// The desired email is already in use for another user (this will throw an error in the database)
70-
if (this.userService.isEmailUsedByAUser(dto.email)) {
69+
// The desired email is already in use for another user (this would also throw an error in the database)
70+
if (await this.userService.isEmailUsedByAUser(dto.email)) {
7171
throw new BadRequestException(ErrorCodes.EmailAlreadyInUse);
7272
}
7373

src/controllers/user-management/user.controller.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -129,12 +129,10 @@ export class UserController {
129129
try {
130130
// Verify that we have admin access to the user and that the user is on an organization
131131
const dbUser = await this.userService.findOneWithOrganizations(id);
132-
if (!dbUser.permissions || dbUser.permissions.length < 1) {
133-
throw new ForbiddenException();
134-
}
135132

136-
// Has to be admin for at least one organization containing the user
137-
if (!dbUser.permissions.some(perm => req.user.permissions.hasUserAdminOnOrganization(perm.organization.id))) {
133+
// Requesting user has to be admin for at least one organization containing the user
134+
// _OR_ be global admin
135+
if (!req.user.permissions.isGlobalAdmin && !dbUser.permissions.some(perm => req.user.permissions.hasUserAdminOnOrganization(perm.organization.id))) {
138136
throw new ForbiddenException();
139137
}
140138

0 commit comments

Comments
 (0)